mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-11-04 05:53:21 +00:00 
			
		
		
		
	Add settings item for sidebar toggle.
This commit is contained in:
		@@ -237,8 +237,7 @@ app.on('ready', () => {
 | 
				
			|||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ipc.on('forward-message', (event, listener, ...params) => {
 | 
						ipc.on('forward-message', (event, listener, ...params) => {
 | 
				
			||||||
		console.log(listener, ...params);
 | 
							page.send(listener, ...params);
 | 
				
			||||||
		page.send(listener);
 | 
					 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ipc.on('register-server-tab-shortcut', (event, index) => {
 | 
						ipc.on('register-server-tab-shortcut', (event, index) => {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,6 +21,7 @@ class ServerManagerView {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		this.$reloadTooltip = $actionsContainer.querySelector('#reload-tooltip');
 | 
							this.$reloadTooltip = $actionsContainer.querySelector('#reload-tooltip');
 | 
				
			||||||
		this.$settingsTooltip = $actionsContainer.querySelector('#setting-tooltip');
 | 
							this.$settingsTooltip = $actionsContainer.querySelector('#setting-tooltip');
 | 
				
			||||||
 | 
							this.$sidebar = document.getElementById('sidebar');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		this.activeTabIndex = -1;
 | 
							this.activeTabIndex = -1;
 | 
				
			||||||
		this.tabs = [];
 | 
							this.tabs = [];
 | 
				
			||||||
@@ -247,6 +248,14 @@ class ServerManagerView {
 | 
				
			|||||||
		ipcRenderer.on('switch-server-tab', (event, index) => {
 | 
							ipcRenderer.on('switch-server-tab', (event, index) => {
 | 
				
			||||||
			this.activateTab(index);
 | 
								this.activateTab(index);
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
							ipcRenderer.on('toggle-sidebar', (event, show) => {
 | 
				
			||||||
 | 
								debugger;
 | 
				
			||||||
 | 
								if (show) {
 | 
				
			||||||
 | 
									this.$sidebar.classList.remove('hidden');
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									this.$sidebar.classList.add('hidden');
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
		ipcRenderer.on('render-taskbar-icon', (event, messageCount) => {
 | 
							ipcRenderer.on('render-taskbar-icon', (event, messageCount) => {
 | 
				
			||||||
			// Create a canvas from unread messagecounts
 | 
								// Create a canvas from unread messagecounts
 | 
				
			||||||
			function createOverlayIcon(messageCount) {
 | 
								function createOverlayIcon(messageCount) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,10 +21,10 @@ class GeneralSection extends BaseComponent {
 | 
				
			|||||||
						<div class="setting-control"></div>
 | 
											<div class="setting-control"></div>
 | 
				
			||||||
					</div>
 | 
										</div>
 | 
				
			||||||
				</div>
 | 
									</div>
 | 
				
			||||||
				<div class="title">App updates</div>
 | 
									<div class="title">App Updates</div>
 | 
				
			||||||
                <div id="betaupdate-option-settings" class="settings-card">
 | 
					                <div id="betaupdate-option-settings" class="settings-card">
 | 
				
			||||||
					<div class="setting-row">
 | 
										<div class="setting-row">
 | 
				
			||||||
						<div class="setting-description">Get Beta updates</div>
 | 
											<div class="setting-description">Get beta updates</div>
 | 
				
			||||||
						<div class="setting-control"></div>
 | 
											<div class="setting-control"></div>
 | 
				
			||||||
					</div>
 | 
										</div>
 | 
				
			||||||
				</div>
 | 
									</div>
 | 
				
			||||||
@@ -35,6 +35,13 @@ class GeneralSection extends BaseComponent {
 | 
				
			|||||||
						<div class="setting-control"></div>
 | 
											<div class="setting-control"></div>
 | 
				
			||||||
					</div>
 | 
										</div>
 | 
				
			||||||
				</div>
 | 
									</div>
 | 
				
			||||||
 | 
									<div class="title">User Interface</div>
 | 
				
			||||||
 | 
					                <div id="ui-option-settings" class="settings-card">
 | 
				
			||||||
 | 
										<div class="setting-row" id="sidebar-option">
 | 
				
			||||||
 | 
											<div class="setting-description">Show sidebar</div>
 | 
				
			||||||
 | 
											<div class="setting-control"></div>
 | 
				
			||||||
 | 
										</div>
 | 
				
			||||||
 | 
									</div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
		`;
 | 
							`;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -67,11 +74,16 @@ class GeneralSection extends BaseComponent {
 | 
				
			|||||||
		this.settingsOptionTemplate(silentOption);
 | 
							this.settingsOptionTemplate(silentOption);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						sidebarToggleTemplate(toggleOption) {
 | 
				
			||||||
 | 
							this.settingsOptionTemplate(toggleOption);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	init() {
 | 
						init() {
 | 
				
			||||||
		this.props.$root.innerHTML = this.template();
 | 
							this.props.$root.innerHTML = this.template();
 | 
				
			||||||
		this.initTrayOption();
 | 
							this.initTrayOption();
 | 
				
			||||||
		this.initUpdateOption();
 | 
							this.initUpdateOption();
 | 
				
			||||||
		this.initSilentOption();
 | 
							this.initSilentOption();
 | 
				
			||||||
 | 
							this.initSidebarToggle();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	initTrayOption() {
 | 
						initTrayOption() {
 | 
				
			||||||
@@ -120,6 +132,23 @@ class GeneralSection extends BaseComponent {
 | 
				
			|||||||
		});
 | 
							});
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						initSidebarToggle() {
 | 
				
			||||||
 | 
							this.$sidebarOptionSettings = document.querySelector('#ui-option-settings #sidebar-option .setting-control');
 | 
				
			||||||
 | 
							this.$sidebarOptionSettings.innerHTML = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							const sidebarOption = ConfigUtil.getConfigItem('show-sidebar', false);
 | 
				
			||||||
 | 
							const $sidebarOption = this.generateNodeFromTemplate(this.settingsOptionTemplate(sidebarOption));
 | 
				
			||||||
 | 
							this.$sidebarOptionSettings.appendChild($sidebarOption);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							$sidebarOption.addEventListener('click', () => {
 | 
				
			||||||
 | 
								const newValue = !ConfigUtil.getConfigItem('show-sidebar');
 | 
				
			||||||
 | 
								ConfigUtil.setConfigItem('show-sidebar', newValue);
 | 
				
			||||||
 | 
								debugger;
 | 
				
			||||||
 | 
								ipcRenderer.send('forward-message', 'toggle-sidebar', newValue);
 | 
				
			||||||
 | 
								this.initSidebarToggle();
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	handleServerInfoChange() {
 | 
						handleServerInfoChange() {
 | 
				
			||||||
		ipcRenderer.send('forward-message', 'reload-viewer');
 | 
							ipcRenderer.send('forward-message', 'reload-viewer');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user