Merge pull request #720 from yuya-oc/fix-tray-settings
Fix app crached after toggling tray icon settings on Mac and Linux
This commit is contained in:
@@ -550,15 +550,17 @@ app.on('ready', () => {
|
||||
// set up context menu for tray icon
|
||||
if (shouldShowTrayIcon()) {
|
||||
const tMenu = trayMenu.createMenu(mainWindow, configData, global.isDev);
|
||||
trayIcon.setContextMenu(tMenu);
|
||||
if (process.platform === 'darwin' || process.platform === 'linux') {
|
||||
// store the information, if the tray was initialized, for checking in the settings, if the application
|
||||
// was restarted after setting "Show icon on menu bar"
|
||||
if (trayIcon) {
|
||||
trayIcon.setContextMenu(tMenu);
|
||||
mainWindow.trayWasVisible = true;
|
||||
} else {
|
||||
mainWindow.trayWasVisible = false;
|
||||
}
|
||||
} else {
|
||||
trayIcon.setContextMenu(tMenu);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@@ -70,6 +70,13 @@ module.exports = {
|
||||
return requireResult.value;
|
||||
});
|
||||
});
|
||||
client.addCommand('waitForAppOptionsAutoSaved', function async() {
|
||||
const ID_APP_OPTIONS_SAVE_INDICATOR = '#appOptionsSaveIndicator';
|
||||
const TIMEOUT = 5000;
|
||||
return this.
|
||||
waitForVisible(ID_APP_OPTIONS_SAVE_INDICATOR, TIMEOUT).
|
||||
waitForVisible(ID_APP_OPTIONS_SAVE_INDICATOR, TIMEOUT, true);
|
||||
});
|
||||
},
|
||||
|
||||
// execute the test only when `condition` is true
|
||||
|
@@ -195,6 +195,27 @@ describe('browser/settings.html', function desc() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Save tray icon setting on mac', () => {
|
||||
env.shouldTest(it, env.isOneOf(['darwin', 'linux']))('should be saved when it\'s selected', () => {
|
||||
env.addClientCommands(this.app.client);
|
||||
return this.app.client.
|
||||
loadSettingsPage().
|
||||
click('#inputShowTrayIcon').
|
||||
waitForAppOptionsAutoSaved().
|
||||
then(() => {
|
||||
const config0 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
||||
config0.showTrayIcon.should.true;
|
||||
return this.app.client;
|
||||
}).
|
||||
click('#inputShowTrayIcon').
|
||||
waitForAppOptionsAutoSaved().
|
||||
then(() => {
|
||||
const config0 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
||||
config0.showTrayIcon.should.false;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Save tray icon theme on linux', () => {
|
||||
env.shouldTest(it, process.platform === 'linux')('should be saved when it\'s selected', () => {
|
||||
env.addClientCommands(this.app.client);
|
||||
|
Reference in New Issue
Block a user