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