forked from lightningpixel/modly
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotification.ts
More file actions
17 lines (17 loc) · 769 Bytes
/
Copy pathnotification.ts
File metadata and controls
17 lines (17 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
* Native OS notification (Windows toast / macOS Notification Center / Linux) for
* events worth surfacing even when the user isn't looking at the app — e.g. a
* generation or workflow run finishing while they're in another window. Plays
* each platform's own default notification sound (the toast isn't `silent`).
*
* Skipped when the app window already has focus: the user is looking right at
* it, so a toast on top would just be noise.
*/
export async function showCompletionNotification(body: string, title = 'Modly'): Promise<void> {
if (typeof document !== 'undefined' && document.hasFocus()) return
try {
await window.electron.notifications.show(title, body)
} catch {
// Notifications not available (e.g. unsupported platform)
}
}