From c009a098c75a4828f69f7ebee2f3e5e3d9e428db Mon Sep 17 00:00:00 2001 From: Lino Schmidt Date: Thu, 7 Jul 2022 01:21:51 +0200 Subject: [PATCH] Added notification badge --- src/index.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 964e494..6db6f0c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,6 +54,10 @@ if (require('electron-squirrel-startup')) { app.quit(); } +if(platform === Platform.Windows) { + app.setAppUserModelId(app.name); +} + const createWindow = () => { // Create the browser window. const mainWindow = new BrowserWindow({ @@ -109,7 +113,15 @@ const createWindow = () => { }); ipcMain.on('setProgress', (event, arg) => { - mainWindow.setProgressBar(parseFloat(arg)); + const progress = parseFloat(arg); + mainWindow.setProgressBar(progress); + if(progress === 1 && !mainWindow.isFocused()) { + app.setBadgeCount(1); + } + }); + + mainWindow.on('focus', () => { + app.setBadgeCount(0); }); mainWindow.on('close', () => { @@ -119,6 +131,8 @@ const createWindow = () => { ipcMain.on('openApp', () => { mainWindow.show(); }); + + mainWindow.setIcon(path.join(__dirname, '../assets/icon.png')); }; // This method will be called when Electron has finished