Skip to content

Commit

Permalink
Js Lint error fixed 🔧, Fixes zulip#110
Browse files Browse the repository at this point in the history
  • Loading branch information
Lplenka committed Apr 2, 2017
1 parent 9ec62a7 commit 460a647
Show file tree
Hide file tree
Showing 9 changed files with 214 additions and 217 deletions.
8 changes: 4 additions & 4 deletions app/main/autoupdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function appUpdater() {
log.transports.file.level = 'info';
autoUpdater.logger = log;
/*
autoUpdater.on('error', err => log.info(err));
AutoUpdater.on('error', err => log.info(err));
autoUpdater.on('checking-for-update', () => log.info('checking-for-update'));
autoUpdater.on('update-available', () => log.info('update-available'));
autoUpdater.on('update-not-available', () => log.info('update-not-available'));
Expand All @@ -17,7 +17,7 @@ function appUpdater() {
// Ask the user if update is available
// eslint-disable-next-line no-unused-vars
autoUpdater.on('update-downloaded', (event, info) => {
// let message = app.getName() + ' ' + info.releaseName + ' is now available. It will be installed the next time you restart the application.';
// Let message = app.getName() + ' ' + info.releaseName + ' is now available. It will be installed the next time you restart the application.';
// if (info.releaseNotes) {
// const splitNotes = info.releaseNotes.split(/[^\r]\n/);
// message += '\n\nRelease notes:\n';
Expand All @@ -38,10 +38,10 @@ function appUpdater() {
}
});
});
// init for updates
// Init for updates
autoUpdater.checkForUpdates();
}

exports = module.exports = {
module.exports = {
appUpdater
};
39 changes: 19 additions & 20 deletions app/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,24 @@ const {dialog} = require('electron');
const https = require('https');
const http = require('http');
const electronLocalshortcut = require('electron-localshortcut');
// const Configstore = require('configstore');
// Not using // const Configstore = require('configstore');
const Configstore = require('electron-config');
const JsonDB = require('node-json-db');
const isDev = require('electron-is-dev');
const tray = require('./tray');
// Not using now //const tray = require('./tray');
const appMenu = require('./menu');
const {linkIsInternal, skipImages} = require('./link-helper');
const {appUpdater} = require('./autoupdater');

const db = new JsonDB(app.getPath('userData') + '/domain.json', true, true);
const data = db.getData('/');

// adds debug features like hotkeys for triggering dev tools and reload
// Adds debug features like hotkeys for triggering dev tools and reload
require('electron-debug')();

// const conf = new Configstore('Zulip-Desktop');
// Const conf = new Configstore('Zulip-Desktop');
const conf = new Configstore();


function userOS() {
if (os.platform() === 'darwin') {
return 'Mac';
Expand All @@ -44,10 +43,10 @@ function userOS() {
}
}

// setting userAgent so that server-side code can identify the desktop app
// Setting userAgent so that server-side code can identify the desktop app
const isUserAgent = 'ZulipElectron/' + app.getVersion() + ' ' + userOS();

// prevent window being garbage collected
// Prevent window being garbage collected
let mainWindow;
let targetLink;

Expand Down Expand Up @@ -162,8 +161,7 @@ function updateDockBadge(title) {
if (process.platform === 'darwin') {
app.setBadgeCount(messageCount);
}
mainWindow.webContents.send('tray', messageCount);

mainWindow.webContents.send('tray', messageCount);
}

function createMainWindow() {
Expand Down Expand Up @@ -223,7 +221,7 @@ function createMainWindow() {
});
});

// on osx it's 'moved'
// On osx it's 'moved'
win.on('move', function () {
const pos = this.getPosition();
conf.set({
Expand All @@ -232,17 +230,18 @@ function createMainWindow() {
});
});

// stop page to update it's title
// Stop page to update it's title
win.on('page-title-updated', (e, title) => {
e.preventDefault();
updateDockBadge(title);
});

//To destroy tray icon when navigate to a new URL
win.webContents.on('will-navigate', (e, url) => {
// console.log(url);
win.webContents.send('destroytray');
});
// To destroy tray icon when navigate to a new URL
win.webContents.on('will-navigate', e => {
if (e) {
win.webContents.send('destroytray');
}
});

return win;
}
Expand All @@ -251,7 +250,7 @@ function createMainWindow() {
app.commandLine.appendSwitch('ignore-certificate-errors', 'true');

app.on('window-all-closed', () => {
// unregister all the shortcuts so that they don't interfare with other apps
// Unregister all the shortcuts so that they don't interfare with other apps
electronLocalshortcut.unregisterAll(mainWindow);
if (process.platform !== 'darwin') {
app.quit();
Expand All @@ -267,7 +266,7 @@ app.on('activate', () => {
app.on('ready', () => {
electron.Menu.setApplicationMenu(appMenu);
mainWindow = createMainWindow();
//tray.create();
// Not using for now // tray.create();

const page = mainWindow.webContents;

Expand Down Expand Up @@ -314,12 +313,12 @@ app.on('ready', () => {
});

app.on('will-quit', () => {
// unregister all the shortcuts so that they don't interfare with other apps
// Unregister all the shortcuts so that they don't interfare with other apps
electronLocalshortcut.unregisterAll(mainWindow);
});

ipc.on('new-domain', (e, domain) => {
// mainWindow.loadURL(domain);
// MainWindow.loadURL(domain);
if (!mainWindow) {
mainWindow = createMainWindow();
mainWindow.loadURL(domain);
Expand Down
2 changes: 1 addition & 1 deletion app/main/link-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ function linkIsInternal(currentUrl, newUrl) {
// We'll be needing this to open images in default browser
const skipImages = '.jpg|.gif|.png|.jpeg|.JPG|.PNG';

exports = module.exports = {
module.exports = {
linkIsInternal, skipImages
};
2 changes: 1 addition & 1 deletion app/main/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const shell = electron.shell;
const appName = app.getName();
const tray = require('./tray');
// Const tray = require('./tray');

const {addDomain, about} = require('./windowmanager');

Expand Down
20 changes: 10 additions & 10 deletions app/main/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ process.once('loaded', () => {

// eslint-disable-next-line import/no-unassigned-import
require('./domain');
// eslint-disable-next-line import/no-unassigned-import
require('../renderer/js/tray.js');
// Calling Tray.js in renderer process everytime app window loads

//Calling Tray.js in renderer process everytime app window loads
require('../renderer/js/Tray.js');

// handle zooming functionality
// Handle zooming functionality
const zoomIn = () => {
webFrame.setZoomFactor(webFrame.getZoomFactor() + 0.1);
};
Expand All @@ -29,7 +29,7 @@ const zoomActualSize = () => {
webFrame.setZoomFactor(1);
};

// get zooming actions from main process
// Get zooming actions from main process
ipcRenderer.on('zoomIn', () => {
zoomIn();
});
Expand All @@ -43,27 +43,27 @@ ipcRenderer.on('zoomActualSize', () => {
});

ipcRenderer.on('log-out', () => {
// create the menu for the below
// Create the menu for the below
document.querySelector('.dropdown-toggle').click();

const nodes = document.querySelectorAll('.dropdown-menu li:last-child a');
nodes[nodes.length - 1].click();
});

ipcRenderer.on('shortcut', () => {
// create the menu for the below
// Create the menu for the below
const node = document.querySelector('a[data-overlay-trigger=keyboard-shortcuts]');
// additional check
// Additional check
if (node.text.trim().toLowerCase() === 'keyboard shortcuts') {
node.click();
} else {
// atleast click the dropdown
// Atleast click the dropdown
document.querySelector('.dropdown-toggle').click();
}
});

// To prevent failing this script on linux we need to load it after the document loaded
document.addEventListener('DOMContentLoaded', () => {
// init spellchecker
// Init spellchecker
spellChecker();
});
2 changes: 1 addition & 1 deletion app/main/spellchecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ function spellChecker() {
});
}

exports = module.exports = {
module.exports = {
spellChecker
};
16 changes: 9 additions & 7 deletions app/main/windowmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let domainWindow;
let aboutWindow;

function onClosed() {
// dereference the window
// Dereference the window
domainWindow = null;
aboutWindow = null;
}
Expand Down Expand Up @@ -65,7 +65,7 @@ function createAboutWindow() {
aboutwin.loadURL(aboutURL);
aboutwin.on('closed', onClosed);

// stop page to update it's title
// Stop page to update it's title
aboutwin.on('page-title-updated', e => {
e.preventDefault();
});
Expand All @@ -84,12 +84,14 @@ function about() {
}

ipc.on('trayabout', event => {
about();
if (event) {
about();
}
});

ipc.on('traychangeserver', event => {
addDomain();
if (event) {
addDomain();
}
});


exports = module.exports = {addDomain, about};
module.exports = {addDomain, about};
Loading

0 comments on commit 460a647

Please sign in to comment.