Skip to content

Commit 9820e59

Browse files
committed
Merge hide-to-tray-icon with show-tray-icon
1 parent 4b0fa94 commit 9820e59

2 files changed

Lines changed: 8 additions & 29 deletions

File tree

‎electron_app/src/electron-main.js‎

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ const store = new Store({ name: "electron-config" });
8686

8787
let mainWindow = null;
8888
global.appQuitting = false;
89-
global.showTrayIcon = store.get("showTrayIcon", true);
90-
global.minimizeToTray = global.showTrayIcon && store.get('minimizeToTray', true);
9189

9290
// It's important to call `path.join` so we don't end up with the packaged asar in the final path.
9391
const iconFile = `riot.${process.platform === 'win32' ? 'ico' : 'png'}`;
@@ -174,25 +172,17 @@ ipcMain.on('ipcCall', async function(ev, payload) {
174172
launcher.disable();
175173
}
176174
break;
177-
case 'getTrayIconEnabled':
178-
ret = global.showTrayIcon;
175+
case 'getMinimizeToTrayEnabled':
176+
ret = tray.hasTray();
179177
break;
180-
case 'setTrayIconEnabled':
178+
case 'setMinimizeToTrayEnabled':
181179
if (args[0]) {
182180
// Create trayIcon icon
183181
tray.create(trayConfig);
184182
} else {
185183
tray.destroy();
186184
}
187-
store.set('minimizeToTray', global.showTrayIcon = args[0]);
188-
// re-evaluate whether we should be minimizing to tray
189-
global.minimizeToTray = global.showTrayIcon && store.get('minimizeToTray', true);
190-
break;
191-
case 'getMinimizeToTrayEnabled':
192-
ret = global.minimizeToTray;
193-
break;
194-
case 'setMinimizeToTrayEnabled':
195-
store.set('minimizeToTray', global.minimizeToTray = args[0]);
185+
store.set('minimizeToTray', args[0]);
196186
break;
197187
case 'getAutoHideMenuBarEnabled':
198188
ret = global.mainWindow.isMenuBarAutoHide();
@@ -388,7 +378,7 @@ app.on('ready', () => {
388378
mainWindow.hide();
389379

390380
// Create trayIcon icon
391-
if (global.showTrayIcon) tray.create(trayConfig);
381+
if (store.get('minimizeToTray', true)) tray.create(trayConfig);
392382

393383
mainWindow.once('ready-to-show', () => {
394384
mainWindowState.manage(mainWindow);
@@ -405,7 +395,8 @@ app.on('ready', () => {
405395
mainWindow = global.mainWindow = null;
406396
});
407397
mainWindow.on('close', (e) => {
408-
if (global.minimizeToTray && !global.appQuitting && (tray.hasTray() || process.platform === 'darwin')) {
398+
// If we are not quitting and have a tray icon then minimize to tray
399+
if (!global.appQuitting && tray.hasTray()) {
409400
// On Mac, closing the window just hides it
410401
// (this is generally how single-window Mac apps
411402
// behave, eg. Mail.app)

‎src/vector/platform/ElectronPlatform.js‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,23 +211,11 @@ export default class ElectronPlatform extends VectorBasePlatform {
211211
return this._ipcCall('setAutoHideMenuBarEnabled', enabled);
212212
}
213213

214-
supportsTrayIcon(): boolean {
214+
supportsMinimizeToTray(): boolean {
215215
// Things other than Mac support tray icons
216216
return !navigator.platform.toUpperCase().includes('MAC');
217217
}
218218

219-
async getTrayIconEnabled(): boolean {
220-
return this._ipcCall('getTrayIconEnabled');
221-
}
222-
223-
async setTrayIconEnabled(enabled: boolean): void {
224-
return this._ipcCall('setTrayIconEnabled', enabled);
225-
}
226-
227-
supportsMinimizeToTray(): boolean {
228-
return true;
229-
}
230-
231219
async getMinimizeToTrayEnabled(): boolean {
232220
return this._ipcCall('getMinimizeToTrayEnabled');
233221
}

0 commit comments

Comments
 (0)