diff options
author | 2021-09-14 11:03:28 +0200 | |
---|---|---|
committer | 2021-09-14 11:03:28 +0200 | |
commit | 087113d8a1214ba4c7df03bfe66747d8d944280c (patch) | |
tree | 4d853a03057138dfa845cd6a7d91ccf63565a1a6 /src/electron/ipc-api/appIndicator.js | |
parent | chore: codebase improvements (#1930) (diff) | |
download | ferdium-app-087113d8a1214ba4c7df03bfe66747d8d944280c.tar.gz ferdium-app-087113d8a1214ba4c7df03bfe66747d8d944280c.tar.zst ferdium-app-087113d8a1214ba4c7df03bfe66747d8d944280c.zip |
chore: convert JS to TS (#1934)
Diffstat (limited to 'src/electron/ipc-api/appIndicator.js')
-rw-r--r-- | src/electron/ipc-api/appIndicator.js | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/src/electron/ipc-api/appIndicator.js b/src/electron/ipc-api/appIndicator.js deleted file mode 100644 index c6c261d0f..000000000 --- a/src/electron/ipc-api/appIndicator.js +++ /dev/null | |||
@@ -1,73 +0,0 @@ | |||
1 | import { app, ipcMain } from 'electron'; | ||
2 | import { join } from 'path'; | ||
3 | import { autorun } from 'mobx'; | ||
4 | import { isMac, isWindows, isLinux } from '../../environment'; | ||
5 | |||
6 | const INDICATOR_TASKBAR = 'taskbar'; | ||
7 | const FILE_EXTENSION = isWindows ? 'ico' : 'png'; | ||
8 | |||
9 | let isTrayIconEnabled; | ||
10 | |||
11 | function getAsset(type, asset) { | ||
12 | return join( | ||
13 | __dirname, '..', '..', 'assets', 'images', type, process.platform, `${asset}.${FILE_EXTENSION}`, | ||
14 | ); | ||
15 | } | ||
16 | |||
17 | export default (params) => { | ||
18 | autorun(() => { | ||
19 | isTrayIconEnabled = params.settings.app.get('enableSystemTray'); | ||
20 | |||
21 | if (!isTrayIconEnabled) { | ||
22 | params.trayIcon.hide(); | ||
23 | } else if (isTrayIconEnabled) { | ||
24 | params.trayIcon.show(); | ||
25 | } | ||
26 | }); | ||
27 | |||
28 | ipcMain.on('updateAppIndicator', (event, args) => { | ||
29 | // Flash TaskBar for windows, bounce Dock on Mac | ||
30 | if (!app.mainWindow.isFocused()) { | ||
31 | if (params.settings.app.get('notifyTaskBarOnMessage')) { | ||
32 | if (isWindows) { | ||
33 | app.mainWindow.flashFrame(true); | ||
34 | app.mainWindow.once('focus', () => app.mainWindow.flashFrame(false)); | ||
35 | } else if (isMac) { | ||
36 | app.dock.bounce('informational'); | ||
37 | } | ||
38 | } | ||
39 | } | ||
40 | |||
41 | // Update badge | ||
42 | if (isMac | ||
43 | && typeof (args.indicator) === 'string') { | ||
44 | app.dock.setBadge(args.indicator); | ||
45 | } | ||
46 | |||
47 | if ((isMac || isLinux) | ||
48 | && typeof (args.indicator) === 'number' | ||
49 | ) { | ||
50 | app.badgeCount = args.indicator; | ||
51 | } | ||
52 | |||
53 | if (isWindows) { | ||
54 | if (typeof args.indicator === 'number' | ||
55 | && args.indicator !== 0) { | ||
56 | params.mainWindow.setOverlayIcon( | ||
57 | getAsset('taskbar', `${INDICATOR_TASKBAR}-${(args.indicator >= 10 ? 10 : args.indicator)}`), | ||
58 | '', | ||
59 | ); | ||
60 | } else if (typeof args.indicator === 'string') { | ||
61 | params.mainWindow.setOverlayIcon( | ||
62 | getAsset('taskbar', `${INDICATOR_TASKBAR}-alert`), | ||
63 | '', | ||
64 | ); | ||
65 | } else { | ||
66 | params.mainWindow.setOverlayIcon(null, ''); | ||
67 | } | ||
68 | } | ||
69 | |||
70 | // Update Tray | ||
71 | params.trayIcon.setIndicator(args.indicator); | ||
72 | }); | ||
73 | }; | ||