Merge pull request #290 from zulip/clear-settings

Added Clear app settings menu item
This commit is contained in:
Akash Nimare
2017-09-07 22:36:43 +05:30
committed by GitHub
3 changed files with 19 additions and 3 deletions

View File

@@ -49,6 +49,10 @@ function createMainWindow() {
defaultWidth: 1000,
defaultHeight: 600
});
// Let's keep the window position global so that we can access it in other process
global.mainWindowState = mainWindowState;
const win = new electron.BrowserWindow({
// This settings needs to be saved in config
title: 'Zulip',
@@ -188,6 +192,12 @@ app.on('ready', () => {
page.send('destroytray');
});
ipcMain.on('clear-app-settings', () => {
global.mainWindowState.unmanage(mainWindow);
app.relaunch();
app.exit();
});
ipcMain.on('toggle-app', () => {
if (mainWindow.isVisible()) {
mainWindow.hide();

View File

@@ -201,6 +201,7 @@ class AppMenu {
type: 'separator'
}, {
label: 'Reset App Settings',
accelerator: 'Command+Shift+D',
click() {
AppMenu.resetAppSettings();
}
@@ -302,6 +303,7 @@ class AppMenu {
type: 'separator'
}, {
label: 'Reset App Settings',
accelerator: 'Ctrl+Shift+D',
click() {
AppMenu.resetAppSettings();
}
@@ -371,7 +373,7 @@ class AppMenu {
const getAppPath = path.join(app.getPath('appData'), appName, 'window-state.json');
fs.unlink(getAppPath, () => {
setTimeout(() => app.relaunch(), app.exit(), 1000);
setTimeout(() => AppMenu.sendAction('clear-app-data'), 1000);
});
}

View File

@@ -1,9 +1,9 @@
'use strict';
require(__dirname + '/js/tray.js');
const {ipcRenderer, remote} = require('electron');
const { ipcRenderer, remote } = require('electron');
const {session} = remote;
const { session } = remote;
const DomainUtil = require(__dirname + '/js/utils/domain-util.js');
const WebView = require(__dirname + '/js/components/webview.js');
@@ -301,6 +301,10 @@ class ServerManagerView {
ipcRenderer.send('reload-full-app');
});
ipcRenderer.on('clear-app-data', () => {
ipcRenderer.send('clear-app-settings');
});
ipcRenderer.on('switch-server-tab', (event, index) => {
this.activateTab(index);
});