aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/Tray.ts
diff options
context:
space:
mode:
authorLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2022-11-07 06:50:40 +0530
committerLibravatar GitHub <noreply@github.com>2022-11-07 01:20:40 +0000
commit93a5de8d8e725cb6fff256a54544d39cf50a16f8 (patch)
tree6772686892a9e63e183109944c2845fcdeeb8939 /src/lib/Tray.ts
parent6.2.1-nightly.40 [skip ci] (diff)
downloadferdium-app-93a5de8d8e725cb6fff256a54544d39cf50a16f8.tar.gz
ferdium-app-93a5de8d8e725cb6fff256a54544d39cf50a16f8.tar.zst
ferdium-app-93a5de8d8e725cb6fff256a54544d39cf50a16f8.zip
Revert "Remove duplicated Toggle.js component" (#742)
Revert "Remove duplicated Toggle.js component (#741)" This reverts commit dd238ae7949e72e3b90235f56e14686cc5231f34.
Diffstat (limited to 'src/lib/Tray.ts')
-rw-r--r--src/lib/Tray.ts36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/lib/Tray.ts b/src/lib/Tray.ts
index dafbb68aa..8e489edde 100644
--- a/src/lib/Tray.ts
+++ b/src/lib/Tray.ts
@@ -20,7 +20,7 @@ const INDICATOR_TRAY_INDIRECT = 'tray-indirect';
20 20
21// TODO: Need to support i18n for a lot of the hard-coded strings in this file 21// TODO: Need to support i18n for a lot of the hard-coded strings in this file
22export default class TrayIcon { 22export default class TrayIcon {
23 tray: Tray | null = null; 23 trayIcon: Tray | null = null;
24 24
25 indicator: string | number = 0; 25 indicator: string | number = 0;
26 26
@@ -97,9 +97,7 @@ export default class TrayIcon {
97 } 97 }
98 98
99 _updateTrayMenu(appSettings): void { 99 _updateTrayMenu(appSettings): void {
100 if (!this.tray) { 100 if (!this.trayIcon) return;
101 return;
102 }
103 101
104 if (appSettings && appSettings.type === 'app') { 102 if (appSettings && appSettings.type === 'app') {
105 this.isAppMuted = appSettings.data.isAppMuted; // save current state after a change 103 this.isAppMuted = appSettings.data.isAppMuted; // save current state after a change
@@ -107,7 +105,7 @@ export default class TrayIcon {
107 105
108 this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate(this)); 106 this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate(this));
109 if (isLinux) { 107 if (isLinux) {
110 this.tray.setContextMenu(this.trayMenu); 108 this.trayIcon.setContextMenu(this.trayMenu);
111 } 109 }
112 } 110 }
113 111
@@ -117,26 +115,26 @@ export default class TrayIcon {
117 } 115 }
118 116
119 _show(): void { 117 _show(): void {
120 if (this.tray) { 118 if (this.trayIcon) {
121 return; 119 return;
122 } 120 }
123 121
124 this.tray = new Tray(this._getAsset('tray', INDICATOR_TRAY_PLAIN)); 122 this.trayIcon = new Tray(this._getAsset('tray', INDICATOR_TRAY_PLAIN));
125 this.tray.setToolTip('Ferdium'); 123 this.trayIcon.setToolTip('Ferdium');
126 124
127 this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate(this)); 125 this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate(this));
128 if (isLinux) { 126 if (isLinux) {
129 this.tray.setContextMenu(this.trayMenu); 127 this.trayIcon.setContextMenu(this.trayMenu);
130 } 128 }
131 129
132 this.tray.on('click', () => { 130 this.trayIcon.on('click', () => {
133 this._toggleWindow(); 131 this._toggleWindow();
134 }); 132 });
135 133
136 if (isMac || isWindows) { 134 if (isMac || isWindows) {
137 this.tray.on('right-click', () => { 135 this.trayIcon.on('right-click', () => {
138 if (this.tray && this.trayMenu) { 136 if (this.trayIcon && this.trayMenu) {
139 this.tray.popUpContextMenu(this.trayMenu); 137 this.trayIcon.popUpContextMenu(this.trayMenu);
140 } 138 }
141 }); 139 });
142 } 140 }
@@ -179,10 +177,10 @@ export default class TrayIcon {
179 } 177 }
180 178
181 _hide(): void { 179 _hide(): void {
182 if (!this.tray) return; 180 if (!this.trayIcon) return;
183 181
184 this.tray.destroy(); 182 this.trayIcon.destroy();
185 this.tray = null; 183 this.trayIcon = null;
186 184
187 if (isMac && this.themeChangeSubscriberId) { 185 if (isMac && this.themeChangeSubscriberId) {
188 systemPreferences.unsubscribeNotification(this.themeChangeSubscriberId); 186 systemPreferences.unsubscribeNotification(this.themeChangeSubscriberId);
@@ -218,16 +216,16 @@ export default class TrayIcon {
218 } 216 }
219 217
220 _refreshIcon(): void { 218 _refreshIcon(): void {
221 if (!this.tray) { 219 if (!this.trayIcon) {
222 return; 220 return;
223 } 221 }
224 222
225 this.tray.setImage( 223 this.trayIcon.setImage(
226 this._getAsset('tray', this._getAssetFromIndicator(this.indicator)), 224 this._getAsset('tray', this._getAssetFromIndicator(this.indicator)),
227 ); 225 );
228 226
229 if (isMac && !macosVersion.isGreaterThanOrEqualTo('11')) { 227 if (isMac && !macosVersion.isGreaterThanOrEqualTo('11')) {
230 this.tray.setPressedImage( 228 this.trayIcon.setPressedImage(
231 this._getAsset( 229 this._getAsset(
232 'tray', 230 'tray',
233 `${this._getAssetFromIndicator(this.indicator)}-active`, 231 `${this._getAssetFromIndicator(this.indicator)}-active`,