Skip to content

Commit 45b892b

Browse files
committed
Wrap Notification into check
1 parent 4744ea3 commit 45b892b

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

main.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {app, BrowserWindow, globalShortcut, powerSaveBlocker } = require('electron/main');
1+
const {app, BrowserWindow, globalShortcut, Notification, powerSaveBlocker } = require('electron/main');
22
const path = require('node:path');
33
const {ipcMain} = require('electron')
44
const http = require('http');
@@ -144,14 +144,18 @@ ipcMain.on("quit", async (event,arg) => {
144144
});
145145

146146
function show_noti(arg) {
147-
try {
148-
const notification = new Notification({
149-
title: 'Wavelog',
150-
body: arg
151-
});
152-
notification.show();
153-
} catch(e) {
154-
console.log("No notification possible on this system / ignoring");
147+
if (Notification.isSupported()) {
148+
try {
149+
const notification = new Notification({
150+
title: 'Wavelog',
151+
body: arg
152+
});
153+
notification.show();
154+
} catch(e) {
155+
console.log("No notification possible on this system / ignoring");
156+
}
157+
} else {
158+
console.log("Notifications are not supported on this platform");
155159
}
156160
}
157161

0 commit comments

Comments
 (0)