aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/Tray.js
diff options
context:
space:
mode:
authorLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-05-12 01:26:51 +0530
committerLibravatar GitHub <noreply@github.com>2021-05-11 21:56:51 +0200
commit80d7ef19dbb4271416bd8b5bbf938e180c57e5f3 (patch)
treeec99db3b3b0727d7ac81c1ead70e17db0c1bb6b3 /src/lib/Tray.js
parentFixing issue with icons being garbled due to misconfiguration of gulp (diff)
downloadferdium-app-80d7ef19dbb4271416bd8b5bbf938e180c57e5f3.tar.gz
ferdium-app-80d7ef19dbb4271416bd8b5bbf938e180c57e5f3.tar.zst
ferdium-app-80d7ef19dbb4271416bd8b5bbf938e180c57e5f3.zip
Method reuse (#1379)
* Used already exported common functions to avoid the same logic being repeated. * Use a different package to retrieve the os-name for the 'About Dialog'.
Diffstat (limited to 'src/lib/Tray.js')
-rw-r--r--src/lib/Tray.js16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/lib/Tray.js b/src/lib/Tray.js
index 36f0de66d..f37b4eb7b 100644
--- a/src/lib/Tray.js
+++ b/src/lib/Tray.js
@@ -3,13 +3,9 @@ import {
3} from 'electron'; 3} from 'electron';
4import path from 'path'; 4import path from 'path';
5import macosVersion from 'macos-version'; 5import macosVersion from 'macos-version';
6import { 6import { isMac, isWindows, isLinux } from '../environment';
7 isMac,
8 isWindows,
9 isLinux,
10} from '../environment';
11 7
12const FILE_EXTENSION = process.platform === 'win32' ? 'ico' : 'png'; 8const FILE_EXTENSION = isWindows ? 'ico' : 'png';
13const INDICATOR_TRAY_PLAIN = 'tray'; 9const INDICATOR_TRAY_PLAIN = 'tray';
14const INDICATOR_TRAY_UNREAD = 'tray-unread'; 10const INDICATOR_TRAY_UNREAD = 'tray-unread';
15const INDICATOR_TRAY_INDIRECT = 'tray-indirect'; 11const INDICATOR_TRAY_INDIRECT = 'tray-indirect';
@@ -110,7 +106,7 @@ export default class TrayIcon {
110 }); 106 });
111 } 107 }
112 108
113 if (process.platform === 'darwin') { 109 if (isMac) {
114 this.themeChangeSubscriberId = systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => { 110 this.themeChangeSubscriberId = systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => {
115 this._refreshIcon(); 111 this._refreshIcon();
116 }); 112 });
@@ -128,7 +124,7 @@ export default class TrayIcon {
128 this.trayIcon.destroy(); 124 this.trayIcon.destroy();
129 this.trayIcon = null; 125 this.trayIcon = null;
130 126
131 if (process.platform === 'darwin' && this.themeChangeSubscriberId) { 127 if (isMac && this.themeChangeSubscriberId) {
132 systemPreferences.unsubscribeNotification(this.themeChangeSubscriberId); 128 systemPreferences.unsubscribeNotification(this.themeChangeSubscriberId);
133 this.themeChangeSubscriberId = null; 129 this.themeChangeSubscriberId = null;
134 } 130 }
@@ -164,7 +160,7 @@ export default class TrayIcon {
164 160
165 this.trayIcon.setImage(this._getAsset('tray', this._getAssetFromIndicator(this.indicator))); 161 this.trayIcon.setImage(this._getAsset('tray', this._getAssetFromIndicator(this.indicator)));
166 162
167 if (process.platform === 'darwin') { 163 if (isMac) {
168 this.trayIcon.setPressedImage( 164 this.trayIcon.setPressedImage(
169 this._getAsset('tray', `${this._getAssetFromIndicator(this.indicator)}-active`), 165 this._getAsset('tray', `${this._getAssetFromIndicator(this.indicator)}-active`),
170 ); 166 );
@@ -174,7 +170,7 @@ export default class TrayIcon {
174 _getAsset(type, asset) { 170 _getAsset(type, asset) {
175 let { platform } = process; 171 let { platform } = process;
176 172
177 if (platform === 'darwin' && (nativeTheme.shouldUseDarkColors || macosVersion.isGreaterThanOrEqualTo('11'))) { 173 if (isMac && (nativeTheme.shouldUseDarkColors || macosVersion.isGreaterThanOrEqualTo('11'))) {
178 platform = `${platform}-dark`; 174 platform = `${platform}-dark`;
179 } 175 }
180 176