aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/Tray.js
diff options
context:
space:
mode:
authorLibravatar Markus Hatvan <markus_hatvan@aon.at>2021-10-15 09:48:06 +0200
committerLibravatar GitHub <noreply@github.com>2021-10-15 09:48:06 +0200
commit14d2364fc69e0222133115c55a36286986006098 (patch)
tree9e9b3c41ef742bbe87ca1632b292c67043051957 /src/lib/Tray.js
parent5.6.3-nightly.34 [skip ci] (diff)
downloadferdium-app-14d2364fc69e0222133115c55a36286986006098.tar.gz
ferdium-app-14d2364fc69e0222133115c55a36286986006098.tar.zst
ferdium-app-14d2364fc69e0222133115c55a36286986006098.zip
chore: update eslint setup (#2074)
Diffstat (limited to 'src/lib/Tray.js')
-rw-r--r--src/lib/Tray.js53
1 files changed, 41 insertions, 12 deletions
diff --git a/src/lib/Tray.js b/src/lib/Tray.js
index 7360611cd..e7afc3552 100644
--- a/src/lib/Tray.js
+++ b/src/lib/Tray.js
@@ -1,5 +1,11 @@
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 macosVersion from 'macos-version';
@@ -65,7 +71,9 @@ export default class TrayIcon {
65 71
66 if (appSettings.type === 'app') { 72 if (appSettings.type === 'app') {
67 const { isAppMuted } = appSettings.data; 73 const { isAppMuted } = appSettings.data;
68 this.trayMenuTemplate[1].label = isAppMuted ? 'Enable Notifications && Audio' : 'Disable Notifications && Audio'; 74 this.trayMenuTemplate[1].label = isAppMuted
75 ? 'Enable Notifications && Audio'
76 : 'Disable Notifications && Audio';
69 this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate); 77 this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate);
70 if (isLinux) { 78 if (isLinux) {
71 this.trayIcon.setContextMenu(this.trayMenu); 79 this.trayIcon.setContextMenu(this.trayMenu);
@@ -108,9 +116,12 @@ export default class TrayIcon {
108 } 116 }
109 117
110 if (isMac) { 118 if (isMac) {
111 this.themeChangeSubscriberId = systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => { 119 this.themeChangeSubscriberId = systemPreferences.subscribeNotification(
112 this._refreshIcon(); 120 'AppleInterfaceThemeChangedNotification',
113 }); 121 () => {
122 this._refreshIcon();
123 },
124 );
114 } 125 }
115 } 126 }
116 127
@@ -150,7 +161,8 @@ export default class TrayIcon {
150 _getAssetFromIndicator(indicator) { 161 _getAssetFromIndicator(indicator) {
151 if (indicator === '•') { 162 if (indicator === '•') {
152 return INDICATOR_TRAY_INDIRECT; 163 return INDICATOR_TRAY_INDIRECT;
153 } if (indicator !== 0) { 164 }
165 if (indicator !== 0) {
154 return INDICATOR_TRAY_UNREAD; 166 return INDICATOR_TRAY_UNREAD;
155 } 167 }
156 return INDICATOR_TRAY_PLAIN; 168 return INDICATOR_TRAY_PLAIN;
@@ -159,11 +171,16 @@ export default class TrayIcon {
159 _refreshIcon() { 171 _refreshIcon() {
160 if (!this.trayIcon) return; 172 if (!this.trayIcon) return;
161 173
162 this.trayIcon.setImage(this._getAsset('tray', this._getAssetFromIndicator(this.indicator))); 174 this.trayIcon.setImage(
175 this._getAsset('tray', this._getAssetFromIndicator(this.indicator)),
176 );
163 177
164 if (isMac) { 178 if (isMac) {
165 this.trayIcon.setPressedImage( 179 this.trayIcon.setPressedImage(
166 this._getAsset('tray', `${this._getAssetFromIndicator(this.indicator)}-active`), 180 this._getAsset(
181 'tray',
182 `${this._getAssetFromIndicator(this.indicator)}-active`,
183 ),
167 ); 184 );
168 } 185 }
169 } 186 }
@@ -171,12 +188,24 @@ export default class TrayIcon {
171 _getAsset(type, asset) { 188 _getAsset(type, asset) {
172 let { platform } = process; 189 let { platform } = process;
173 190
174 if (isMac && (nativeTheme.shouldUseDarkColors || macosVersion.isGreaterThanOrEqualTo('11'))) { 191 if (
192 isMac &&
193 (nativeTheme.shouldUseDarkColors ||
194 macosVersion.isGreaterThanOrEqualTo('11'))
195 ) {
175 platform = `${platform}-dark`; 196 platform = `${platform}-dark`;
176 } 197 }
177 198
178 return nativeImage.createFromPath(join( 199 return nativeImage.createFromPath(
179 __dirname, '..', 'assets', 'images', type, platform, `${asset}.${FILE_EXTENSION}`, 200 join(
180 )); 201 __dirname,
202 '..',
203 'assets',
204 'images',
205 type,
206 platform,
207 `${asset}.${FILE_EXTENSION}`,
208 ),
209 );
181 } 210 }
182} 211}