Skip to content

Commit 231e7fd

Browse files
priyank-pakashnimare
authored andcommitted
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.
1 parent a0d898a commit 231e7fd

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

app/renderer/js/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@ class ServerManagerView {
262262
tabs: this.tabs,
263263
activeTabIndex: this.activeTabIndex
264264
});
265+
266+
ipcRenderer.on('toggle-sidebar', (event, state) => {
267+
const selector = 'webview:not([class*=disabled])';
268+
const webview = document.querySelector(selector);
269+
const webContents = webview.getWebContents();
270+
webContents.send('toggle-sidebar', state);
271+
});
265272
}
266273

267274
destroyTab(name, index) {

app/renderer/js/pages/preference/preference.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ class PreferenceView extends BaseComponent {
7373
ipcRenderer.on('switch-settings-nav', (event, navItem) => {
7474
this.handleNavigation(navItem);
7575
});
76+
77+
ipcRenderer.on('toggle-sidebar', (event, state) => {
78+
const inputSelector = '#sidebar-option .action .switch input';
79+
const input = document.querySelector(inputSelector);
80+
input.checked = state;
81+
});
82+
83+
ipcRenderer.on('toggletray', (event, state) => {
84+
const inputSelector = '#tray-option .action .switch input';
85+
const input = document.querySelector(inputSelector);
86+
input.checked = state;
87+
});
7688
}
7789
}
7890

app/renderer/js/tray.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,16 @@ ipcRenderer.on('tray', (event, arg) => {
197197
});
198198

199199
function toggleTray() {
200+
let state;
200201
if (window.tray) {
202+
state = false;
201203
window.tray.destroy();
202204
if (window.tray.isDestroyed()) {
203205
window.tray = null;
204206
}
205207
ConfigUtil.setConfigItem('trayIcon', false);
206208
} else {
209+
state = true;
207210
createTray();
208211
if (process.platform === 'linux' || process.platform === 'win32') {
209212
renderNativeImage(unread).then(image => {
@@ -213,6 +216,10 @@ function toggleTray() {
213216
}
214217
ConfigUtil.setConfigItem('trayIcon', true);
215218
}
219+
const selector = 'webview:not([class*=disabled])';
220+
const webview = document.querySelector(selector);
221+
const webContents = webview.getWebContents();
222+
webContents.send('toggletray', state);
216223
}
217224

218225
ipcRenderer.on('toggletray', toggleTray);

0 commit comments

Comments
 (0)