diff options
author | Markus Hatvan <markus_hatvan@aon.at> | 2021-10-10 10:42:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-10 10:42:20 +0200 |
commit | a673c2b577a31437c91a0b498e69b0753d62aa58 (patch) | |
tree | 50d52df3ff9d78828ca06a24ef438e31b062ca56 /src/electron/ipc-api/appIndicator.ts | |
parent | remove unused 'conventional-changelog' npm package. Change the url for the ch... (diff) | |
download | ferdium-app-a673c2b577a31437c91a0b498e69b0753d62aa58.tar.gz ferdium-app-a673c2b577a31437c91a0b498e69b0753d62aa58.tar.zst ferdium-app-a673c2b577a31437c91a0b498e69b0753d62aa58.zip |
chore: convert index file to TS (#2049)
Diffstat (limited to 'src/electron/ipc-api/appIndicator.ts')
-rw-r--r-- | src/electron/ipc-api/appIndicator.ts | 34 |
1 files changed, 23 insertions, 11 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 | }; |