mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-11-04 05:53:21 +00:00 
			
		
		
		
	Fix lint errors.
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
				
			|||||||
"use strict";
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class BaseComponent {
 | 
					class BaseComponent {
 | 
				
			||||||
	generateNodeFromTemplate(template) {
 | 
						generateNodeFromTemplate(template) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,7 +18,7 @@ class Tab extends BaseComponent {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	template() {
 | 
						template() {
 | 
				
			||||||
        if (this.type == Tab.SERVER_TAB) {
 | 
							if (this.type === Tab.SERVER_TAB) {
 | 
				
			||||||
			return `<div class="tab" domain="${this.url}">
 | 
								return `<div class="tab" domain="${this.url}">
 | 
				
			||||||
						<div class="server-tab-badge"></div>
 | 
											<div class="server-tab-badge"></div>
 | 
				
			||||||
						<div class="server-tab" style="background-image: url(${this.icon});"></div>
 | 
											<div class="server-tab" style="background-image: url(${this.icon});"></div>
 | 
				
			||||||
@@ -43,7 +43,7 @@ class Tab extends BaseComponent {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	updateBadge(count) {
 | 
						updateBadge(count) {
 | 
				
			||||||
		if (count > 0) {
 | 
							if (count > 0) {
 | 
				
			||||||
			const formattedCount = count > 999? '1K+': count;
 | 
								const formattedCount = count > 999 ? '1K+' : count;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			this.$badge.innerHTML = formattedCount;
 | 
								this.$badge.innerHTML = formattedCount;
 | 
				
			||||||
			this.$badge.classList.add('active');
 | 
								this.$badge.classList.add('active');
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@
 | 
				
			|||||||
const DomainUtil = require(__dirname + '/../utils/domain-util.js');
 | 
					const DomainUtil = require(__dirname + '/../utils/domain-util.js');
 | 
				
			||||||
const SystemUtil = require(__dirname + '/../utils/system-util.js');
 | 
					const SystemUtil = require(__dirname + '/../utils/system-util.js');
 | 
				
			||||||
const {linkIsInternal, skipImages} = require(__dirname + '/../../../main/link-helper');
 | 
					const {linkIsInternal, skipImages} = require(__dirname + '/../../../main/link-helper');
 | 
				
			||||||
const {app, dialog} = require('electron').remote;
 | 
					const {app, dialog, shell} = require('electron').remote;
 | 
				
			||||||
const {ipcRenderer} = require('electron');
 | 
					const {ipcRenderer} = require('electron');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const BaseComponent = require(__dirname + '/../components/base.js');
 | 
					const BaseComponent = require(__dirname + '/../components/base.js');
 | 
				
			||||||
@@ -69,8 +69,8 @@ class WebView extends BaseComponent {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		this.$el.addEventListener('dom-ready', this.show.bind(this));
 | 
							this.$el.addEventListener('dom-ready', this.show.bind(this));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.$el.addEventListener('did-fail-load', (event) => {
 | 
							this.$el.addEventListener('did-fail-load', event => {
 | 
				
			||||||
			const {errorCode, errorDescription, validatedURL} = event;
 | 
								const {errorDescription} = event;
 | 
				
			||||||
			const hasConnectivityErr = (this.systemUtil.connectivityERR.indexOf(errorDescription) >= 0);
 | 
								const hasConnectivityErr = (this.systemUtil.connectivityERR.indexOf(errorDescription) >= 0);
 | 
				
			||||||
			if (hasConnectivityErr) {
 | 
								if (hasConnectivityErr) {
 | 
				
			||||||
				console.error('error', errorDescription);
 | 
									console.error('error', errorDescription);
 | 
				
			||||||
@@ -89,16 +89,18 @@ class WebView extends BaseComponent {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	getBadgeCount(title) {
 | 
						getBadgeCount(title) {
 | 
				
			||||||
		let messageCountInTitle = (/\(([0-9]+)\)/).exec(title);
 | 
							const messageCountInTitle = (/\(([0-9]+)\)/).exec(title);
 | 
				
			||||||
		return messageCountInTitle ? Number(messageCountInTitle[1]) : 0;
 | 
							return messageCountInTitle ? Number(messageCountInTitle[1]) : 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	show() {
 | 
						show() {
 | 
				
			||||||
		// Do not show WebView if another tab was selected and this tab should be in background.
 | 
							// Do not show WebView if another tab was selected and this tab should be in background.
 | 
				
			||||||
		if (!this.isActive()) return;
 | 
							if (!this.isActive()) {
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		this.$el.classList.remove('disabled');
 | 
							this.$el.classList.remove('disabled');
 | 
				
			||||||
        this.focus()
 | 
							this.focus();
 | 
				
			||||||
		this.loading = false;
 | 
							this.loading = false;
 | 
				
			||||||
		this.onTitleChange(this.$el.getTitle());
 | 
							this.onTitleChange(this.$el.getTitle());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,11 +1,9 @@
 | 
				
			|||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require(__dirname + '/js/tray.js');
 | 
					require(__dirname + '/js/tray.js');
 | 
				
			||||||
 | 
					const {ipcRenderer} = require('electron');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const DomainUtil = require(__dirname + '/js/utils/domain-util.js');
 | 
					const DomainUtil = require(__dirname + '/js/utils/domain-util.js');
 | 
				
			||||||
const SystemUtil = require(__dirname + '/js/utils/system-util.js');
 | 
					 | 
				
			||||||
const {linkIsInternal, skipImages} = require(__dirname + '/../main/link-helper');
 | 
					 | 
				
			||||||
const {shell, ipcRenderer} = require('electron');
 | 
					 | 
				
			||||||
const WebView = require(__dirname + '/js/components/webview.js');
 | 
					const WebView = require(__dirname + '/js/components/webview.js');
 | 
				
			||||||
const Tab = require(__dirname + '/js/components/tab.js');
 | 
					const Tab = require(__dirname + '/js/components/tab.js');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -36,7 +34,7 @@ class ServerManagerView {
 | 
				
			|||||||
		const servers = this.domainUtil.getDomains();
 | 
							const servers = this.domainUtil.getDomains();
 | 
				
			||||||
		if (servers.length > 0) {
 | 
							if (servers.length > 0) {
 | 
				
			||||||
			for (let i = 0; i < servers.length; i++) {
 | 
								for (let i = 0; i < servers.length; i++) {
 | 
				
			||||||
				this.initServer(servers[i], i)
 | 
									this.initServer(servers[i], i);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			this.activateTab(0);
 | 
								this.activateTab(0);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
@@ -55,10 +53,12 @@ class ServerManagerView {
 | 
				
			|||||||
		}));
 | 
							}));
 | 
				
			||||||
		this.webviews.push(new WebView({
 | 
							this.webviews.push(new WebView({
 | 
				
			||||||
			$root: this.$content,
 | 
								$root: this.$content,
 | 
				
			||||||
			index: index,
 | 
								index,
 | 
				
			||||||
			url: server.url,
 | 
								url: server.url,
 | 
				
			||||||
			name: server.alias,
 | 
								name: server.alias,
 | 
				
			||||||
			isActive: () => {return index == this.activeTabIndex},
 | 
								isActive: () => {
 | 
				
			||||||
 | 
									return index === this.activeTabIndex;
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
			onTitleChange: this.updateBadge.bind(this),
 | 
								onTitleChange: this.updateBadge.bind(this),
 | 
				
			||||||
			nodeIntegration: false
 | 
								nodeIntegration: false
 | 
				
			||||||
		}));
 | 
							}));
 | 
				
			||||||
@@ -82,7 +82,7 @@ class ServerManagerView {
 | 
				
			|||||||
		this.settingsTabIndex = this.webviews.length;
 | 
							this.settingsTabIndex = this.webviews.length;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		this.tabs.push(new Tab({
 | 
							this.tabs.push(new Tab({
 | 
				
			||||||
			url: url,
 | 
								url,
 | 
				
			||||||
			name: 'Settings',
 | 
								name: 'Settings',
 | 
				
			||||||
			type: Tab.SETTINGS_TAB,
 | 
								type: Tab.SETTINGS_TAB,
 | 
				
			||||||
			$root: this.$tabsContainer,
 | 
								$root: this.$tabsContainer,
 | 
				
			||||||
@@ -92,9 +92,11 @@ class ServerManagerView {
 | 
				
			|||||||
		this.webviews.push(new WebView({
 | 
							this.webviews.push(new WebView({
 | 
				
			||||||
			$root: this.$content,
 | 
								$root: this.$content,
 | 
				
			||||||
			index: this.settingsTabIndex,
 | 
								index: this.settingsTabIndex,
 | 
				
			||||||
			url: url,
 | 
								url,
 | 
				
			||||||
			name: "Settings",
 | 
								name: 'Settings',
 | 
				
			||||||
			isActive: () => {return this.settingsTabIndex == this.activeTabIndex},
 | 
								isActive: () => {
 | 
				
			||||||
 | 
									return this.settingsTabIndex === this.activeTabIndex;
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
			onTitleChange: this.updateBadge.bind(this),
 | 
								onTitleChange: this.updateBadge.bind(this),
 | 
				
			||||||
			nodeIntegration: true
 | 
								nodeIntegration: true
 | 
				
			||||||
		}));
 | 
							}));
 | 
				
			||||||
@@ -137,16 +139,16 @@ class ServerManagerView {
 | 
				
			|||||||
	registerIpcs() {
 | 
						registerIpcs() {
 | 
				
			||||||
		const webviewListeners = {
 | 
							const webviewListeners = {
 | 
				
			||||||
			'webview-reload': 'reload',
 | 
								'webview-reload': 'reload',
 | 
				
			||||||
			'back': 'back',
 | 
								back: 'back',
 | 
				
			||||||
			'focus': 'focus',
 | 
								focus: 'focus',
 | 
				
			||||||
			'forward': 'forward',
 | 
								forward: 'forward',
 | 
				
			||||||
			'zoomIn': 'zoomIn',
 | 
								zoomIn: 'zoomIn',
 | 
				
			||||||
			'zoomOut': 'zoomOut',
 | 
								zoomOut: 'zoomOut',
 | 
				
			||||||
			'zoomActualSize': 'zoomActualSize',
 | 
								zoomActualSize: 'zoomActualSize',
 | 
				
			||||||
			'log-out': 'logOut',
 | 
								'log-out': 'logOut',
 | 
				
			||||||
			'shortcut': 'showShortcut',
 | 
								shortcut: 'showShortcut',
 | 
				
			||||||
			'tab-devtools': 'openDevTools'
 | 
								'tab-devtools': 'openDevTools'
 | 
				
			||||||
		}
 | 
							};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (const key in webviewListeners) {
 | 
							for (const key in webviewListeners) {
 | 
				
			||||||
			ipcRenderer.on(key, () => {
 | 
								ipcRenderer.on(key, () => {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user