diff options
author | 2021-08-16 23:13:06 +0530 | |
---|---|---|
committer | 2021-08-16 23:13:06 +0530 | |
commit | bbed06e2ba255199703343625129712ef7707697 (patch) | |
tree | 19a525fbd1d621a6e561b1a687195269e54f43d5 /src/lib/Tray.js | |
parent | chore: update outdated node_modules (#1807) (diff) | |
download | ferdium-app-bbed06e2ba255199703343625129712ef7707697.tar.gz ferdium-app-bbed06e2ba255199703343625129712ef7707697.tar.zst ferdium-app-bbed06e2ba255199703343625129712ef7707697.zip |
Revert "chore: update outdated node_modules (#1807)"
This reverts commit 26a9dba22236bc22a7612107630282cfe02d20e0.
Diffstat (limited to 'src/lib/Tray.js')
-rw-r--r-- | src/lib/Tray.js | 55 |
1 files changed, 13 insertions, 42 deletions
diff --git a/src/lib/Tray.js b/src/lib/Tray.js index c629e212d..f5970f7e7 100644 --- a/src/lib/Tray.js +++ b/src/lib/Tray.js | |||
@@ -1,14 +1,8 @@ | |||
1 | import { | 1 | import { |
2 | app, | 2 | app, Menu, nativeImage, nativeTheme, systemPreferences, Tray, ipcMain, |
3 | Menu, | ||
4 | nativeImage, | ||
5 | nativeTheme, | ||
6 | systemPreferences, | ||
7 | Tray, | ||
8 | ipcMain, | ||
9 | } from 'electron'; | 3 | } from 'electron'; |
10 | import { join } from 'path'; | 4 | import { join } from 'path'; |
11 | import { isMacOSVersionGreaterThanOrEqualTo } from 'macos-version'; | 5 | import macosVersion from 'macos-version'; |
12 | import { isMac, isWindows, isLinux } from '../environment'; | 6 | import { isMac, isWindows, isLinux } from '../environment'; |
13 | 7 | ||
14 | const FILE_EXTENSION = isWindows ? 'ico' : 'png'; | 8 | const FILE_EXTENSION = isWindows ? 'ico' : 'png'; |
@@ -70,9 +64,7 @@ export default class TrayIcon { | |||
70 | 64 | ||
71 | if (appSettings.type === 'app') { | 65 | if (appSettings.type === 'app') { |
72 | const { isAppMuted } = appSettings.data; | 66 | const { isAppMuted } = appSettings.data; |
73 | this.trayMenuTemplate[1].label = isAppMuted | 67 | this.trayMenuTemplate[1].label = isAppMuted ? 'Enable Notifications && Audio' : 'Disable Notifications && Audio'; |
74 | ? 'Enable Notifications && Audio' | ||
75 | : 'Disable Notifications && Audio'; | ||
76 | this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate); | 68 | this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate); |
77 | if (isLinux) { | 69 | if (isLinux) { |
78 | this.trayIcon.setContextMenu(this.trayMenu); | 70 | this.trayIcon.setContextMenu(this.trayMenu); |
@@ -115,12 +107,9 @@ export default class TrayIcon { | |||
115 | } | 107 | } |
116 | 108 | ||
117 | if (isMac) { | 109 | if (isMac) { |
118 | this.themeChangeSubscriberId = systemPreferences.subscribeNotification( | 110 | this.themeChangeSubscriberId = systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => { |
119 | 'AppleInterfaceThemeChangedNotification', | 111 | this._refreshIcon(); |
120 | () => { | 112 | }); |
121 | this._refreshIcon(); | ||
122 | }, | ||
123 | ); | ||
124 | } | 113 | } |
125 | } | 114 | } |
126 | 115 | ||
@@ -160,8 +149,7 @@ export default class TrayIcon { | |||
160 | _getAssetFromIndicator(indicator) { | 149 | _getAssetFromIndicator(indicator) { |
161 | if (indicator === '•') { | 150 | if (indicator === '•') { |
162 | return INDICATOR_TRAY_INDIRECT; | 151 | return INDICATOR_TRAY_INDIRECT; |
163 | } | 152 | } if (indicator !== 0) { |
164 | if (indicator !== 0) { | ||
165 | return INDICATOR_TRAY_UNREAD; | 153 | return INDICATOR_TRAY_UNREAD; |
166 | } | 154 | } |
167 | return INDICATOR_TRAY_PLAIN; | 155 | return INDICATOR_TRAY_PLAIN; |
@@ -170,16 +158,11 @@ export default class TrayIcon { | |||
170 | _refreshIcon() { | 158 | _refreshIcon() { |
171 | if (!this.trayIcon) return; | 159 | if (!this.trayIcon) return; |
172 | 160 | ||
173 | this.trayIcon.setImage( | 161 | this.trayIcon.setImage(this._getAsset('tray', this._getAssetFromIndicator(this.indicator))); |
174 | this._getAsset('tray', this._getAssetFromIndicator(this.indicator)), | ||
175 | ); | ||
176 | 162 | ||
177 | if (isMac) { | 163 | if (isMac) { |
178 | this.trayIcon.setPressedImage( | 164 | this.trayIcon.setPressedImage( |
179 | this._getAsset( | 165 | this._getAsset('tray', `${this._getAssetFromIndicator(this.indicator)}-active`), |
180 | 'tray', | ||
181 | `${this._getAssetFromIndicator(this.indicator)}-active`, | ||
182 | ), | ||
183 | ); | 166 | ); |
184 | } | 167 | } |
185 | } | 168 | } |
@@ -187,24 +170,12 @@ export default class TrayIcon { | |||
187 | _getAsset(type, asset) { | 170 | _getAsset(type, asset) { |
188 | let { platform } = process; | 171 | let { platform } = process; |
189 | 172 | ||
190 | if ( | 173 | if (isMac && (nativeTheme.shouldUseDarkColors || macosVersion.isGreaterThanOrEqualTo('11'))) { |
191 | isMac && | ||
192 | (nativeTheme.shouldUseDarkColors || | ||
193 | isMacOSVersionGreaterThanOrEqualTo('11')) | ||
194 | ) { | ||
195 | platform = `${platform}-dark`; | 174 | platform = `${platform}-dark`; |
196 | } | 175 | } |
197 | 176 | ||
198 | return nativeImage.createFromPath( | 177 | return nativeImage.createFromPath(join( |
199 | join( | 178 | __dirname, '..', 'assets', 'images', type, platform, `${asset}.${FILE_EXTENSION}`, |
200 | __dirname, | 179 | )); |
201 | '..', | ||
202 | 'assets', | ||
203 | 'images', | ||
204 | type, | ||
205 | platform, | ||
206 | `${asset}.${FILE_EXTENSION}`, | ||
207 | ), | ||
208 | ); | ||
209 | } | 180 | } |
210 | } | 181 | } |