mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-14 02:47:49 +00:00
Add reset app settings menu item #286
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
const { app, shell, BrowserWindow, Menu } = require('electron');
|
const { app, shell, BrowserWindow, Menu } = require('electron');
|
||||||
|
|
||||||
|
const fs = require('fs-extra');
|
||||||
|
|
||||||
const ConfigUtil = require(__dirname + '/../renderer/js/utils/config-util.js');
|
const ConfigUtil = require(__dirname + '/../renderer/js/utils/config-util.js');
|
||||||
|
|
||||||
const appName = app.getName();
|
const appName = app.getName();
|
||||||
@@ -195,6 +199,11 @@ class AppMenu {
|
|||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
type: 'separator'
|
type: 'separator'
|
||||||
|
}, {
|
||||||
|
label: 'Reset App Settings',
|
||||||
|
click() {
|
||||||
|
AppMenu.resetAppSettings();
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
label: 'Log Out',
|
label: 'Log Out',
|
||||||
accelerator: 'Cmd+L',
|
accelerator: 'Cmd+L',
|
||||||
@@ -291,6 +300,11 @@ class AppMenu {
|
|||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
type: 'separator'
|
type: 'separator'
|
||||||
|
}, {
|
||||||
|
label: 'Reset App Settings',
|
||||||
|
click() {
|
||||||
|
AppMenu.resetAppSettings();
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
label: 'Log Out',
|
label: 'Log Out',
|
||||||
accelerator: 'Ctrl+L',
|
accelerator: 'Ctrl+L',
|
||||||
@@ -353,6 +367,14 @@ class AppMenu {
|
|||||||
win.webContents.send(action, ...params);
|
win.webContents.send(action, ...params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static resetAppSettings() {
|
||||||
|
const getAppPath = path.join(app.getPath('appData'), appName, 'window-state.json');
|
||||||
|
|
||||||
|
fs.unlink(getAppPath, () => {
|
||||||
|
setTimeout(() => AppMenu.sendAction('hard-reload'), 1000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setMenu(props) {
|
setMenu(props) {
|
||||||
const tpl = process.platform === 'darwin' ? this.getDarwinTpl(props) : this.getOtherTpl(props);
|
const tpl = process.platform === 'darwin' ? this.getDarwinTpl(props) : this.getOtherTpl(props);
|
||||||
const menu = Menu.buildFromTemplate(tpl);
|
const menu = Menu.buildFromTemplate(tpl);
|
||||||
|
|||||||
Reference in New Issue
Block a user