diff options
Diffstat (limited to 'src/electron')
-rw-r--r-- | src/electron/ipc-api/appIndicator.ts | 34 | ||||
-rw-r--r-- | src/electron/ipc-api/index.ts | 2 |
2 files changed, 24 insertions, 12 deletions
diff --git a/src/electron/ipc-api/appIndicator.ts b/src/electron/ipc-api/appIndicator.ts index a51ed8161..bd5f6a68f 100644 --- a/src/electron/ipc-api/appIndicator.ts +++ b/src/electron/ipc-api/appIndicator.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { app, ipcMain } from 'electron'; | 1 | import { app, ipcMain, BrowserWindow, Tray } from 'electron'; |
2 | import { join } from 'path'; | 2 | import { join } from 'path'; |
3 | import { autorun } from 'mobx'; | 3 | import { autorun } from 'mobx'; |
4 | import { isMac, isWindows, isLinux } from '../../environment'; | 4 | import { isMac, isWindows, isLinux } from '../../environment'; |
@@ -21,29 +21,38 @@ function getAsset(type: 'tray' | 'taskbar', asset: string) { | |||
21 | ); | 21 | ); |
22 | } | 22 | } |
23 | 23 | ||
24 | export default params => { | 24 | export default (params: { |
25 | mainWindow: BrowserWindow; | ||
26 | settings: any; | ||
27 | trayIcon: Tray; | ||
28 | }) => { | ||
25 | autorun(() => { | 29 | autorun(() => { |
26 | isTrayIconEnabled = params.settings.app.get('enableSystemTray'); | 30 | isTrayIconEnabled = params.settings.app.get('enableSystemTray'); |
27 | 31 | ||
28 | if (!isTrayIconEnabled) { | 32 | if (!isTrayIconEnabled) { |
33 | // @ts-expect-error Property 'hide' does not exist on type 'Tray'. | ||
29 | params.trayIcon.hide(); | 34 | params.trayIcon.hide(); |
30 | } else if (isTrayIconEnabled) { | 35 | } else if (isTrayIconEnabled) { |
36 | // @ts-expect-error Property 'show' does not exist on type 'Tray'. | ||
31 | params.trayIcon.show(); | 37 | params.trayIcon.show(); |
32 | } | 38 | } |
33 | }); | 39 | }); |
34 | 40 | ||
35 | ipcMain.on('updateAppIndicator', (_event, args) => { | 41 | ipcMain.on('updateAppIndicator', (_event, args) => { |
36 | // Flash TaskBar for windows, bounce Dock on Mac | 42 | // Flash TaskBar for windows, bounce Dock on Mac |
37 | if (!(app as any).mainWindow.isFocused() && params.settings.app.get('notifyTaskBarOnMessage')) { | 43 | if ( |
38 | if (isWindows) { | 44 | !params.mainWindow.isFocused() && |
39 | (app as any).mainWindow.flashFrame(true); | 45 | params.settings.app.get('notifyTaskBarOnMessage') |
40 | (app as any).mainWindow.once('focus', () => | 46 | ) { |
41 | (app as any).mainWindow.flashFrame(false), | 47 | if (isWindows) { |
42 | ); | 48 | params.mainWindow.flashFrame(true); |
43 | } else if (isMac) { | 49 | params.mainWindow.once('focus', () => |
44 | app.dock.bounce('informational'); | 50 | params.mainWindow.flashFrame(false), |
45 | } | 51 | ); |
52 | } else if (isMac) { | ||
53 | app.dock.bounce('informational'); | ||
46 | } | 54 | } |
55 | } | ||
47 | 56 | ||
48 | // Update badge | 57 | // Update badge |
49 | if (isMac && typeof args.indicator === 'string') { | 58 | if (isMac && typeof args.indicator === 'string') { |
@@ -57,6 +66,7 @@ export default params => { | |||
57 | if (isWindows) { | 66 | if (isWindows) { |
58 | if (typeof args.indicator === 'number' && args.indicator !== 0) { | 67 | if (typeof args.indicator === 'number' && args.indicator !== 0) { |
59 | params.mainWindow.setOverlayIcon( | 68 | params.mainWindow.setOverlayIcon( |
69 | // @ts-expect-error Argument of type 'string' is not assignable to parameter of type 'NativeImage | null'. | ||
60 | getAsset( | 70 | getAsset( |
61 | 'taskbar', | 71 | 'taskbar', |
62 | `${INDICATOR_TASKBAR}-${ | 72 | `${INDICATOR_TASKBAR}-${ |
@@ -67,6 +77,7 @@ export default params => { | |||
67 | ); | 77 | ); |
68 | } else if (typeof args.indicator === 'string') { | 78 | } else if (typeof args.indicator === 'string') { |
69 | params.mainWindow.setOverlayIcon( | 79 | params.mainWindow.setOverlayIcon( |
80 | // @ts-expect-error Argument of type 'string' is not assignable to parameter of type 'NativeImage | null'. | ||
70 | getAsset('taskbar', `${INDICATOR_TASKBAR}-alert`), | 81 | getAsset('taskbar', `${INDICATOR_TASKBAR}-alert`), |
71 | '', | 82 | '', |
72 | ); | 83 | ); |
@@ -76,6 +87,7 @@ export default params => { | |||
76 | } | 87 | } |
77 | 88 | ||
78 | // Update Tray | 89 | // Update Tray |
90 | // @ts-expect-error Property 'setIndicator' does not exist on type 'Tray'. | ||
79 | params.trayIcon.setIndicator(args.indicator); | 91 | params.trayIcon.setIndicator(args.indicator); |
80 | }); | 92 | }); |
81 | }; | 93 | }; |
diff --git a/src/electron/ipc-api/index.ts b/src/electron/ipc-api/index.ts index f03f61517..1f69c04ee 100644 --- a/src/electron/ipc-api/index.ts +++ b/src/electron/ipc-api/index.ts | |||
@@ -12,7 +12,7 @@ import focusState from './focusState'; | |||
12 | export default (params: { | 12 | export default (params: { |
13 | mainWindow: BrowserWindow; | 13 | mainWindow: BrowserWindow; |
14 | settings: any; | 14 | settings: any; |
15 | tray: Tray; | 15 | trayIcon: Tray; |
16 | }) => { | 16 | }) => { |
17 | settings(params); | 17 | settings(params); |
18 | sessionStorage(); | 18 | sessionStorage(); |