mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-11 02:30:21 +08:00
es6(*): Fix application ES6 conversion
This commit is contained in:
parent
cbde54eb8f
commit
84ad1d26ba
1 changed files with 10 additions and 10 deletions
|
@ -8,7 +8,6 @@ import SharedFileManager from './shared-file-manager';
|
||||||
|
|
||||||
import {BrowserWindow, Menu, app, ipcMain, dialog} from 'electron';
|
import {BrowserWindow, Menu, app, ipcMain, dialog} from 'electron';
|
||||||
|
|
||||||
import _ from 'underscore';
|
|
||||||
import fs from 'fs-plus';
|
import fs from 'fs-plus';
|
||||||
import url from 'url';
|
import url from 'url';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
@ -18,7 +17,7 @@ let clipboard = null;
|
||||||
|
|
||||||
// The application's singleton class.
|
// The application's singleton class.
|
||||||
//
|
//
|
||||||
export default class Application {
|
export default class Application extends EventEmitter {
|
||||||
start(options) {
|
start(options) {
|
||||||
const {resourcePath, configDirPath, version, devMode, specMode, safeMode} = options;
|
const {resourcePath, configDirPath, version, devMode, specMode, safeMode} = options;
|
||||||
|
|
||||||
|
@ -156,7 +155,7 @@ export default class Application {
|
||||||
deleteFileWithRetry(filePath, callback = () => {}, retries = 5) {
|
deleteFileWithRetry(filePath, callback = () => {}, retries = 5) {
|
||||||
const callbackWithRetry = (err) => {
|
const callbackWithRetry = (err) => {
|
||||||
if (err && (err.message.indexOf('no such file') === -1)) {
|
if (err && (err.message.indexOf('no such file') === -1)) {
|
||||||
console.log("File Error: ${err.message} - retrying in 150msec");
|
console.log(`File Error: ${err.message} - retrying in 150msec`);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.deleteFileWithRetry(filePath, callback, retries - 1);
|
this.deleteFileWithRetry(filePath, callback, retries - 1);
|
||||||
}, 150);
|
}, 150);
|
||||||
|
@ -221,7 +220,7 @@ export default class Application {
|
||||||
|
|
||||||
setDatabasePhase(phase) {
|
setDatabasePhase(phase) {
|
||||||
if (!['setup', 'ready', 'close'].includes(phase)) {
|
if (!['setup', 'ready', 'close'].includes(phase)) {
|
||||||
throw new Error("setDatabasePhase: ${phase} is invalid.");
|
throw new Error(`setDatabasePhase: ${phase} is invalid.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (phase === this._databasePhase) {
|
if (phase === this._databasePhase) {
|
||||||
|
@ -328,6 +327,7 @@ export default class Application {
|
||||||
win.show()
|
win.show()
|
||||||
win.focus()
|
win.focus()
|
||||||
});
|
});
|
||||||
|
|
||||||
this.on('application:check-for-update', () => {
|
this.on('application:check-for-update', () => {
|
||||||
this.autoUpdateManager.check();
|
this.autoUpdateManager.check();
|
||||||
});
|
});
|
||||||
|
@ -469,9 +469,9 @@ export default class Application {
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('call-window-method', (event, method, ...args) => {
|
ipcMain.on('call-window-method', (event, method, ...args) => {
|
||||||
const win = BrowserWindow.fromWebContents(event.sender)
|
const win = BrowserWindow.fromWebContents(event.sender);
|
||||||
if (!win[method]) {
|
if (!win[method]) {
|
||||||
console.error("Method ${method} does not exist on BrowserWindow!");
|
console.error(`Method ${method} does not exist on BrowserWindow!`);
|
||||||
}
|
}
|
||||||
win[method](...args)
|
win[method](...args)
|
||||||
});
|
});
|
||||||
|
@ -485,9 +485,9 @@ export default class Application {
|
||||||
|
|
||||||
ipcMain.on('call-webcontents-method', (event, method, ...args) => {
|
ipcMain.on('call-webcontents-method', (event, method, ...args) => {
|
||||||
if (!event.sender[method]) {
|
if (!event.sender[method]) {
|
||||||
console.error("Method ${method} does not exist on WebContents!");
|
console.error(`Method ${method} does not exist on WebContents!`);
|
||||||
event.sender[method](...args);
|
|
||||||
}
|
}
|
||||||
|
event.sender[method](...args);
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('action-bridge-rebroadcast-to-all', (event, ...args) => {
|
ipcMain.on('action-bridge-rebroadcast-to-all', (event, ...args) => {
|
||||||
|
@ -600,6 +600,8 @@ export default class Application {
|
||||||
// nylasWindow - The {NylasWindow} to send the command to.
|
// nylasWindow - The {NylasWindow} to send the command to.
|
||||||
// args - The optional arguments to pass along.
|
// args - The optional arguments to pass along.
|
||||||
sendCommandToWindow = (command, nylasWindow, ...args) => {
|
sendCommandToWindow = (command, nylasWindow, ...args) => {
|
||||||
|
console.log('sendCommandToWindow');
|
||||||
|
console.log(command);
|
||||||
if (this.emit(command, ...args)) {
|
if (this.emit(command, ...args)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -684,5 +686,3 @@ export default class Application {
|
||||||
this.windowManager.ensureWindow(WindowManager.SPEC_WINDOW, specWindowOptions);
|
this.windowManager.ensureWindow(WindowManager.SPEC_WINDOW, specWindowOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_.extend(Application.prototype, EventEmitter.prototype);
|
|
||||||
|
|
Loading…
Reference in a new issue