mirror of https://github.com/vector-im/riot-web
Allow configuration of whether closing window closes or minimizes to tray
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/8908/head
parent
588030141b
commit
714570443d
|
@ -7,6 +7,7 @@
|
|||
"author": "New Vector Ltd.",
|
||||
"dependencies": {
|
||||
"auto-launch": "^5.0.1",
|
||||
"electron-store": "^2.0.0",
|
||||
"electron-window-state": "^4.1.0",
|
||||
"minimist": "^1.2.0",
|
||||
"png-to-ico": "^1.0.2"
|
||||
|
|
|
@ -35,6 +35,7 @@ const updater = require('./updater');
|
|||
const { migrateFromOldOrigin } = require('./originMigrator');
|
||||
|
||||
const windowStateKeeper = require('electron-window-state');
|
||||
const Store = require('electron-store');
|
||||
|
||||
// boolean flag set whilst we are doing one-time origin migration
|
||||
// We only serve the origin migration script while we're actually
|
||||
|
@ -55,8 +56,11 @@ try {
|
|||
// Continue with the defaults (ie. an empty config)
|
||||
}
|
||||
|
||||
const store = new Store();
|
||||
|
||||
let mainWindow = null;
|
||||
global.appQuitting = false;
|
||||
global.minimizeToTray = store.get('minimizeToTray', true);
|
||||
|
||||
|
||||
// handle uncaught errors otherwise it displays
|
||||
|
@ -136,6 +140,12 @@ ipcMain.on('ipcCall', async function(ev, payload) {
|
|||
launcher.disable();
|
||||
}
|
||||
break;
|
||||
case 'getMinimizeToTrayEnabled':
|
||||
ret = global.minimizeToTray;
|
||||
break;
|
||||
case 'setMinimizeToTrayEnabled':
|
||||
store.set('minimizeToTray', global.minimizeToTray = args[0]);
|
||||
break;
|
||||
case 'getAppVersion':
|
||||
ret = app.getVersion();
|
||||
break;
|
||||
|
@ -331,7 +341,7 @@ app.on('ready', () => {
|
|||
mainWindow = global.mainWindow = null;
|
||||
});
|
||||
mainWindow.on('close', (e) => {
|
||||
if (!global.appQuitting && (tray.hasTray() || process.platform === 'darwin')) {
|
||||
if (global.minimizeToTray && !global.appQuitting && (tray.hasTray() || process.platform === 'darwin')) {
|
||||
// On Mac, closing the window just hides it
|
||||
// (this is generally how single-window Mac apps
|
||||
// behave, eg. Mail.app)
|
||||
|
|
|
@ -182,10 +182,22 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
return await this._ipcCall('getAutoLaunchEnabled');
|
||||
}
|
||||
|
||||
async setAutoLaunchEnabled(enabled) {
|
||||
async setAutoLaunchEnabled(enabled: boolean) {
|
||||
return await this._ipcCall('setAutoLaunchEnabled', enabled);
|
||||
}
|
||||
|
||||
supportsMinimizeToTray() {
|
||||
return true;
|
||||
}
|
||||
|
||||
async getMinimizeToTrayEnabled() {
|
||||
return await this._ipcCall('getMinimizeToTrayEnabled');
|
||||
}
|
||||
|
||||
async setMinimizeToTrayEnabled(enabled: boolean) {
|
||||
return await this._ipcCall('setMinimizeToTrayEnabled', enabled);
|
||||
}
|
||||
|
||||
async canSelfUpdate(): boolean {
|
||||
const feedUrl = await this._ipcCall('getUpdateFeedUrl');
|
||||
return Boolean(feedUrl);
|
||||
|
|
|
@ -88,19 +88,6 @@ export default class VectorBasePlatform extends BasePlatform {
|
|||
this._updateFavicon();
|
||||
}
|
||||
|
||||
supportsAutoLaunch() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// XXX: Surely this should be a setting like any other?
|
||||
async getAutoLaunchEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
async setAutoLaunchEnabled(enabled) {
|
||||
throw new Error("Unimplemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin update polling, if applicable
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue