mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-11-04 05:53:21 +00:00 
			
		
		
		
	Fix linting errors.
This commit is contained in:
		@@ -1,10 +1,11 @@
 | 
				
			|||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {ipcRenderer} = require('electron');
 | 
					const {ipcRenderer} = require('electron');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const BaseComponent = require(__dirname + '/../../components/base.js');
 | 
					const BaseComponent = require(__dirname + '/../../components/base.js');
 | 
				
			||||||
const ConfigUtil = require(__dirname + '/../../utils/config-util.js');
 | 
					const ConfigUtil = require(__dirname + '/../../utils/config-util.js');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class GeneralSection extends BaseComponent{
 | 
					class GeneralSection extends BaseComponent {
 | 
				
			||||||
	constructor(props) {
 | 
						constructor(props) {
 | 
				
			||||||
		super();
 | 
							super();
 | 
				
			||||||
		this.props = props;
 | 
							this.props = props;
 | 
				
			||||||
@@ -53,15 +54,15 @@ class GeneralSection extends BaseComponent{
 | 
				
			|||||||
		const $trayOption = this.generateNodeFromTemplate(this.trayOptionTemplate(trayOption));
 | 
							const $trayOption = this.generateNodeFromTemplate(this.trayOptionTemplate(trayOption));
 | 
				
			||||||
		this.$trayOptionSettings.appendChild($trayOption);
 | 
							this.$trayOptionSettings.appendChild($trayOption);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$trayOption.addEventListener('click', event=> {
 | 
							$trayOption.addEventListener('click', () => {
 | 
				
			||||||
			const newValue = !ConfigUtil.getConfigItem('trayIcon');
 | 
								const newValue = !ConfigUtil.getConfigItem('trayIcon');
 | 
				
			||||||
			ConfigUtil.setConfigItem('trayIcon', newValue);
 | 
								ConfigUtil.setConfigItem('trayIcon', newValue);
 | 
				
			||||||
			ipcRenderer.send('forward', 'toggletray');
 | 
								ipcRenderer.send('forward', 'toggletray');
 | 
				
			||||||
			this.initTrayOption();
 | 
								this.initTrayOption();
 | 
				
			||||||
		})
 | 
							});
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	handleServerInfoChange(index) {
 | 
						handleServerInfoChange() {
 | 
				
			||||||
		ipcRenderer.send('reload-main');
 | 
							ipcRenderer.send('reload-main');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@ class PreferenceNav extends BaseComponent {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	template() {
 | 
						template() {
 | 
				
			||||||
		let navItemsTemplate = '';
 | 
							let navItemsTemplate = '';
 | 
				
			||||||
		for (let navItem of this.navItems) {
 | 
							for (const navItem of this.navItems) {
 | 
				
			||||||
			navItemsTemplate += `<div class="nav" id="nav-${navItem}">${navItem}</div>`;
 | 
								navItemsTemplate += `<div class="nav" id="nav-${navItem}">${navItem}</div>`;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -35,16 +35,16 @@ class PreferenceNav extends BaseComponent {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	registerListeners() {
 | 
						registerListeners() {
 | 
				
			||||||
		for (let navItem of this.navItems) {
 | 
							for (const navItem of this.navItems) {
 | 
				
			||||||
			const $item = document.getElementById(`nav-${navItem}`);
 | 
								const $item = document.getElementById(`nav-${navItem}`);
 | 
				
			||||||
			$item.addEventListener('click', event => {
 | 
								$item.addEventListener('click', () => {
 | 
				
			||||||
				this.props.onItemSelected(navItem);
 | 
									this.props.onItemSelected(navItem);
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	select(navItemToSelect) {
 | 
						select(navItemToSelect) {
 | 
				
			||||||
		for (let navItem of this.navItems) {
 | 
							for (const navItem of this.navItems) {
 | 
				
			||||||
			if (navItem === navItemToSelect) {
 | 
								if (navItem === navItemToSelect) {
 | 
				
			||||||
				this.activate(navItem);
 | 
									this.activate(navItem);
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,12 +1,9 @@
 | 
				
			|||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {ipcRenderer} = require('electron');
 | 
					 | 
				
			||||||
const BaseComponent = require(__dirname + '/../../components/base.js');
 | 
					const BaseComponent = require(__dirname + '/../../components/base.js');
 | 
				
			||||||
 | 
					 | 
				
			||||||
const DomainUtil = require(__dirname + '/../../utils/domain-util.js');
 | 
					const DomainUtil = require(__dirname + '/../../utils/domain-util.js');
 | 
				
			||||||
const Nav = require(__dirname + '/nav.js');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class NewServerForm extends BaseComponent{
 | 
					class NewServerForm extends BaseComponent {
 | 
				
			||||||
	constructor(props) {
 | 
						constructor(props) {
 | 
				
			||||||
		super();
 | 
							super();
 | 
				
			||||||
		this.props = props;
 | 
							this.props = props;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,15 +1,15 @@
 | 
				
			|||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {ipcRenderer} = require('electron');
 | 
					 | 
				
			||||||
const BaseComponent = require(__dirname + '/js/components/base.js');
 | 
					const BaseComponent = require(__dirname + '/js/components/base.js');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
const Nav = require(__dirname + '/js/pages/preference/nav.js');
 | 
					const Nav = require(__dirname + '/js/pages/preference/nav.js');
 | 
				
			||||||
const ServersSection = require(__dirname + '/js/pages/preference/servers-section.js');
 | 
					const ServersSection = require(__dirname + '/js/pages/preference/servers-section.js');
 | 
				
			||||||
const GeneralSection = require(__dirname + '/js/pages/preference/general-section.js');
 | 
					const GeneralSection = require(__dirname + '/js/pages/preference/general-section.js');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PreferenceView {
 | 
					class PreferenceView extends BaseComponent {
 | 
				
			||||||
	constructor() {
 | 
						constructor() {
 | 
				
			||||||
 | 
							super();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		this.$sidebarContainer = document.getElementById('sidebar');
 | 
							this.$sidebarContainer = document.getElementById('sidebar');
 | 
				
			||||||
		this.$settingsContainer = document.getElementById('settings-container');
 | 
							this.$settingsContainer = document.getElementById('settings-container');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -37,6 +37,7 @@ class PreferenceView {
 | 
				
			|||||||
				});
 | 
									});
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								default: break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		this.section.init();
 | 
							this.section.init();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,12 +1,9 @@
 | 
				
			|||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {ipcRenderer} = require('electron');
 | 
					 | 
				
			||||||
const BaseComponent = require(__dirname + '/../../components/base.js');
 | 
					const BaseComponent = require(__dirname + '/../../components/base.js');
 | 
				
			||||||
 | 
					 | 
				
			||||||
const DomainUtil = require(__dirname + '/../../utils/domain-util.js');
 | 
					const DomainUtil = require(__dirname + '/../../utils/domain-util.js');
 | 
				
			||||||
const Nav = require(__dirname + '/nav.js');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ServerInfoForm extends BaseComponent{
 | 
					class ServerInfoForm extends BaseComponent {
 | 
				
			||||||
	constructor(props) {
 | 
						constructor(props) {
 | 
				
			||||||
		super();
 | 
							super();
 | 
				
			||||||
		this.props = props;
 | 
							this.props = props;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,15 +1,15 @@
 | 
				
			|||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {ipcRenderer} = require('electron');
 | 
					const {ipcRenderer} = require('electron');
 | 
				
			||||||
const BaseComponent = require(__dirname + '/../../components/base.js');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const BaseComponent = require(__dirname + '/../../components/base.js');
 | 
				
			||||||
const DomainUtil = require(__dirname + '/../../utils/domain-util.js');
 | 
					const DomainUtil = require(__dirname + '/../../utils/domain-util.js');
 | 
				
			||||||
const Nav = require(__dirname + '/nav.js');
 | 
					 | 
				
			||||||
const ServerInfoForm = require(__dirname + '/server-info-form.js');
 | 
					const ServerInfoForm = require(__dirname + '/server-info-form.js');
 | 
				
			||||||
const NewServerForm = require(__dirname + '/new-server-form.js');
 | 
					const NewServerForm = require(__dirname + '/new-server-form.js');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ServersSection {
 | 
					class ServersSection extends BaseComponent {
 | 
				
			||||||
	constructor(props) {
 | 
						constructor(props) {
 | 
				
			||||||
 | 
							super();
 | 
				
			||||||
		this.props = props;
 | 
							this.props = props;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -73,7 +73,7 @@ class ServersSection {
 | 
				
			|||||||
		});
 | 
							});
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	handleServerInfoChange(index) {
 | 
						handleServerInfoChange() {
 | 
				
			||||||
		ipcRenderer.send('reload-main');
 | 
							ipcRenderer.send('reload-main');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,7 +47,8 @@ const config = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const renderCanvas = function (arg) {
 | 
					const renderCanvas = function (arg) {
 | 
				
			||||||
	config.unreadCount = arg;
 | 
						config.unreadCount = arg;
 | 
				
			||||||
	return new Promise((resolve, reject) => {
 | 
					
 | 
				
			||||||
 | 
						return new Promise(resolve => {
 | 
				
			||||||
		const SIZE = config.size * config.pixelRatio;
 | 
							const SIZE = config.size * config.pixelRatio;
 | 
				
			||||||
		const PADDING = SIZE * 0.05;
 | 
							const PADDING = SIZE * 0.05;
 | 
				
			||||||
		const CENTER = SIZE / 2;
 | 
							const CENTER = SIZE / 2;
 | 
				
			||||||
@@ -161,7 +162,9 @@ const createTray = function () {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ipcRenderer.on('destroytray', event => {
 | 
					ipcRenderer.on('destroytray', event => {
 | 
				
			||||||
	if (!window.tray) return;
 | 
						if (!window.tray) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	window.tray.destroy();
 | 
						window.tray.destroy();
 | 
				
			||||||
	if (window.tray.isDestroyed()) {
 | 
						if (window.tray.isDestroyed()) {
 | 
				
			||||||
@@ -174,7 +177,9 @@ ipcRenderer.on('destroytray', event => {
 | 
				
			|||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ipcRenderer.on('tray', (event, arg) => {
 | 
					ipcRenderer.on('tray', (event, arg) => {
 | 
				
			||||||
	if (!window.tray) return;
 | 
						if (!window.tray) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (arg === 0) {
 | 
						if (arg === 0) {
 | 
				
			||||||
		unread = arg;
 | 
							unread = arg;
 | 
				
			||||||
@@ -191,7 +196,6 @@ ipcRenderer.on('tray', (event, arg) => {
 | 
				
			|||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function toggleTray() {
 | 
					function toggleTray() {
 | 
				
			||||||
	console.log(window.tray);
 | 
					 | 
				
			||||||
	if (window.tray) {
 | 
						if (window.tray) {
 | 
				
			||||||
		window.tray.destroy();
 | 
							window.tray.destroy();
 | 
				
			||||||
		if (window.tray.isDestroyed()) {
 | 
							if (window.tray.isDestroyed()) {
 | 
				
			||||||
@@ -202,7 +206,7 @@ function toggleTray() {
 | 
				
			|||||||
		createTray();
 | 
							createTray();
 | 
				
			||||||
		renderNativeImage(unread).then(image => {
 | 
							renderNativeImage(unread).then(image => {
 | 
				
			||||||
			window.tray.setImage(image);
 | 
								window.tray.setImage(image);
 | 
				
			||||||
			window.tray.setToolTip(arg + ' unread messages');
 | 
								window.tray.setToolTip(unread + ' unread messages');
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
		ConfigUtil.setConfigItem('trayIcon', true);
 | 
							ConfigUtil.setConfigItem('trayIcon', true);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,8 +17,8 @@ class ConfigUtil {
 | 
				
			|||||||
		return instance;
 | 
							return instance;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	getConfigItem(key, defaultValue=null) {
 | 
						getConfigItem(key, defaultValue = null) {
 | 
				
			||||||
		let value = this.db.getData('/')[key];
 | 
							const value = this.db.getData('/')[key];
 | 
				
			||||||
		if (value === undefined) {
 | 
							if (value === undefined) {
 | 
				
			||||||
			this.setConfigItem(key, value);
 | 
								this.setConfigItem(key, value);
 | 
				
			||||||
			return defaultValue;
 | 
								return defaultValue;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user