Fix linting errors.

This commit is contained in:
Zhongyi Tong
2017-06-18 02:28:50 +08:00
parent f3cf2229c6
commit 9cff5c5a4d
8 changed files with 27 additions and 89 deletions

View File

@@ -1,55 +0,0 @@
'use strict';
const path = require('path');
const {BrowserWindow, ipcMain} = require('electron');
let aboutWindow;
function onClosed() {
// Dereference the window
domainWindow = null;
aboutWindow = null;
}
// About window
function createAboutWindow() {
const aboutwin = new electron.BrowserWindow({
width: 500,
height: 500,
title: 'About Zulip Desktop',
show: false,
center: true,
fullscreen: false,
fullscreenable: false,
resizable: false
});
const aboutURL = 'file://' + path.join(__dirname, '../renderer', 'about.html');
aboutwin.loadURL(aboutURL);
aboutwin.on('closed', onClosed);
// Stop page to update it's title
aboutwin.on('page-title-updated', e => {
e.preventDefault();
});
aboutwin.on('closed', onClosed);
return aboutwin;
}
// Call this onClick About in tray
function about() {
aboutWindow = createAboutWindow();
aboutWindow.once('ready-to-show', () => {
aboutWindow.show();
});
}
ipcMain.on('trayabout', event => {
if (event) {
about();
}
});
module.exports = {
addDomain,
about
};

View File

@@ -270,8 +270,10 @@ const otherTpl = [
submenu: [
{
label: 'Zulip desktop',
click() {
about();
click(item, focusedWindow) {
if (focusedWindow) {
sendAction('open-about');
}
}
},
{

View File

@@ -3,10 +3,6 @@
const Tab = require(__dirname + '/../components/tab.js');
class FunctionalTab extends Tab {
constructor(props) {
super(props);
}
template() {
return `<div class="tab">
<div class="server-tab-badge close-button">
@@ -17,7 +13,7 @@ class FunctionalTab extends Tab {
</div>
</div>`;
}
init() {
this.$el = this.generateNodeFromTemplate(this.template());
this.props.$root.appendChild(this.$el);
@@ -37,7 +33,7 @@ class FunctionalTab extends Tab {
this.$closeButton.classList.remove('active');
});
this.$closeButton.addEventListener('click', (e) => {
this.$closeButton.addEventListener('click', e => {
this.props.onDestroy();
e.stopPropagation();
});

View File

@@ -3,10 +3,6 @@
const Tab = require(__dirname + '/../components/tab.js');
class ServerTab extends Tab {
constructor(props) {
super(props);
}
template() {
return `<div class="tab">
<div class="server-tab-badge"></div>

View File

@@ -13,7 +13,7 @@ class WebView extends BaseComponent {
super();
this.props = props;
this.zoomFactor = 1.0;
this.loading = false;
this.badgeCount = 0;

View File

@@ -68,10 +68,9 @@ class ServerManagerView {
this.$addServerButton.addEventListener('click', this.openSettings.bind(this));
this.$settingsButton.addEventListener('click', this.openSettings.bind(this));
}
openFunctionalTab(tabProps) {
const {name, materialIcon, url} = tabProps;
if (this.functionalTabs.hasOwnProperty(name)) {
if (this.functionalTabs.name) {
this.activateTab(this.functionalTabs[name]);
return;
}
@@ -102,21 +101,21 @@ class ServerManagerView {
openSettings() {
this.openFunctionalTab({
name: 'Settings',
materialIcon: 'settings',
url: `file://${__dirname}/preference.html`
name: 'Settings',
materialIcon: 'settings',
url: `file://${__dirname}/preference.html`
});
}
openAbout() {
this.openFunctionalTab({
name: 'About',
materialIcon: 'sentiment_very_satisfied',
url: `file://${__dirname}/about.html`
});
name: 'About',
materialIcon: 'sentiment_very_satisfied',
url: `file://${__dirname}/about.html`
});
}
activateTab(index, hideOldTab=true) {
activateTab(index, hideOldTab = true) {
if (this.webviews[index].loading) {
return;
}
@@ -154,10 +153,10 @@ class ServerManagerView {
updateBadge() {
let messageCountAll = 0;
for (let i = 0; i < this.webviews.length; i++) {
if (this.tabs[i] && this.tabs[i].hasOwnProperty('updateBadge')) {
if (this.tabs[i] && this.tabs[i].updateBadge) {
const count = this.webviews[i].badgeCount;
messageCountAll += count;
this.tabs[i].updateBadge(count);
this.tabs[i].updateBadge(count);
}
}

View File

@@ -25,7 +25,7 @@ class DomainUtil {
this.db.delete('/domain');
}
return instance;
return instance;
}
getDomains() {

View File

@@ -15,15 +15,15 @@ class LinkUtil {
return instance;
}
isInternal(currentUrl, newUrl) {
const currentDomain = wurl('hostname', currentUrl);
const newDomain = wurl('hostname', newUrl);
isInternal(currentUrl, newUrl) {
const currentDomain = wurl('hostname', currentUrl);
const newDomain = wurl('hostname', newUrl);
const skipImages = '.jpg|.gif|.png|.jpeg|.JPG|.PNG';
const skipImages = '.jpg|.gif|.png|.jpeg|.JPG|.PNG';
// We'll be needing this to open images in default browser
return (currentDomain === newDomain) || newUrl.match(skipImages);
}
// We'll be needing this to open images in default browser
return (currentDomain === newDomain) || newUrl.match(skipImages);
}
}
module.exports = new LinkUtil();