From 5cbe8cade51f91e16fd953206f72d0253249fbb3 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 12 May 2023 12:29:55 +0800 Subject: [PATCH] open package page if notification is clicked (#599) Co-authored-by: neil molina --- modules/desktop/electron/libs/push-notification.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/desktop/electron/libs/push-notification.ts b/modules/desktop/electron/libs/push-notification.ts index 7a16bd2..a591b89 100644 --- a/modules/desktop/electron/libs/push-notification.ts +++ b/modules/desktop/electron/libs/push-notification.ts @@ -2,7 +2,7 @@ import Pushy from "pushy-electron"; import { readSessionData } from "./auth"; import { post } from "./v1-client"; import log from "./logger"; -import { Notification, BrowserWindow } from "electron"; +import { Notification, BrowserWindow, shell } from "electron"; import { isInstalled, nameToSlug } from "./package"; import { getInstalledPackages, @@ -46,10 +46,16 @@ export default function initialize(mainWindow: BrowserWindow) { const installed = isInstalled(pkg); const isDup = await wasReceivedBefore(data); if (!isDup && installed) { - new Notification({ + const notification = new Notification({ title: "tea", - body: data?.message as string - }).show(); + body: data?.message as string, + actions: [{ type: "button", text: "Open" }] + }); + notification.on("click", () => { + shell.openExternal(data?.url); + }); + notification.show(); + log.info("notification shown", data); const v = app.dock.getBadge(); if (!v) {