mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-01 04:23:30 +00:00
preferences page: Reflect changes in the preference page. (#362)
This updated the setting page if the sidebar was toggled using a shortcut. This also updates the setting page if the tray was toggled using menu. Fixes: #304.
This commit is contained in:
@@ -262,6 +262,13 @@ class ServerManagerView {
|
||||
tabs: this.tabs,
|
||||
activeTabIndex: this.activeTabIndex
|
||||
});
|
||||
|
||||
ipcRenderer.on('toggle-sidebar', (event, state) => {
|
||||
const selector = 'webview:not([class*=disabled])';
|
||||
const webview = document.querySelector(selector);
|
||||
const webContents = webview.getWebContents();
|
||||
webContents.send('toggle-sidebar', state);
|
||||
});
|
||||
}
|
||||
|
||||
destroyTab(name, index) {
|
||||
|
||||
@@ -73,6 +73,18 @@ class PreferenceView extends BaseComponent {
|
||||
ipcRenderer.on('switch-settings-nav', (event, navItem) => {
|
||||
this.handleNavigation(navItem);
|
||||
});
|
||||
|
||||
ipcRenderer.on('toggle-sidebar', (event, state) => {
|
||||
const inputSelector = '#sidebar-option .action .switch input';
|
||||
const input = document.querySelector(inputSelector);
|
||||
input.checked = state;
|
||||
});
|
||||
|
||||
ipcRenderer.on('toggletray', (event, state) => {
|
||||
const inputSelector = '#tray-option .action .switch input';
|
||||
const input = document.querySelector(inputSelector);
|
||||
input.checked = state;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -197,13 +197,16 @@ ipcRenderer.on('tray', (event, arg) => {
|
||||
});
|
||||
|
||||
function toggleTray() {
|
||||
let state;
|
||||
if (window.tray) {
|
||||
state = false;
|
||||
window.tray.destroy();
|
||||
if (window.tray.isDestroyed()) {
|
||||
window.tray = null;
|
||||
}
|
||||
ConfigUtil.setConfigItem('trayIcon', false);
|
||||
} else {
|
||||
state = true;
|
||||
createTray();
|
||||
if (process.platform === 'linux' || process.platform === 'win32') {
|
||||
renderNativeImage(unread).then(image => {
|
||||
@@ -213,6 +216,10 @@ function toggleTray() {
|
||||
}
|
||||
ConfigUtil.setConfigItem('trayIcon', true);
|
||||
}
|
||||
const selector = 'webview:not([class*=disabled])';
|
||||
const webview = document.querySelector(selector);
|
||||
const webContents = webview.getWebContents();
|
||||
webContents.send('toggletray', state);
|
||||
}
|
||||
|
||||
ipcRenderer.on('toggletray', toggleTray);
|
||||
|
||||
Reference in New Issue
Block a user