diff --git a/src/browser/application.es6 b/src/browser/application.es6 index ae522f5ce..f74f04d7e 100644 --- a/src/browser/application.es6 +++ b/src/browser/application.es6 @@ -328,15 +328,18 @@ export default class Application extends EventEmitter { }); this.on('application:new-message', () => { - this.windowManager.sendToWindow(WindowManager.MAIN_WINDOW, 'new-message'); + const main = this.windowManager.get(WindowManager.MAIN_WINDOW); + if (main) { main.sendMessage('new-message') } }); + this.on('application:view-help', () => { const helpUrl = 'https://nylas.zendesk.com/hc/en-us/sections/203638587-N1'; require('electron').shell.openExternal(helpUrl); }); this.on('application:open-preferences', () => { - this.windowManager.sendToWindow(WindowManager.MAIN_WINDOW, 'open-preferences'); + const main = this.windowManager.get(WindowManager.MAIN_WINDOW); + if (main) { main.sendMessage('open-preferences') } }); this.on('application:show-main-window', () => { @@ -663,14 +666,16 @@ export default class Application extends EventEmitter { openUrl(urlToOpen) { const {protocol} = url.parse(urlToOpen); if (protocol === 'mailto:') { - this.windowManager.sendToWindow(WindowManager.MAIN_WINDOW, 'mailto', urlToOpen); + const main = this.windowManager.get(WindowManager.MAIN_WINDOW); + if (main) { main.sendMessage('mailto', urlToOpen) } } else { console.log(`Ignoring unknown URL type: ${urlToOpen}`); } } openComposerWithFiles(pathsToOpen) { - this.windowManager.sendToWindow(WindowManager.MAIN_WINDOW, 'mailfiles', pathsToOpen); + const main = this.windowManager.get(WindowManager.MAIN_WINDOW); + if (main) { main.sendMessage('mailfiles', pathsToOpen) } } // Opens up a new {NylasWindow} to run specs within. diff --git a/src/browser/window-manager.es6 b/src/browser/window-manager.es6 index 1844be808..b425b9afc 100644 --- a/src/browser/window-manager.es6 +++ b/src/browser/window-manager.es6 @@ -111,13 +111,6 @@ export default class WindowManager { } } - sendToWindow(windowKey, ...args) { - if (!this._windows[windowKey]) { - throw new Error(`Can't find window: ${windowKey}`); - } - this._windows[windowKey].sendMessage(...args); - } - sendToAllWindows(msg, {except}, ...args) { for (const windowKey of Object.keys(this._windows)) { const win = this._windows[windowKey];