From 7bf8d18a026924d21f7dbe12d853aa6f76c86202 Mon Sep 17 00:00:00 2001 From: Mark Hahnenberg Date: Wed, 25 Jan 2017 12:22:43 -0800 Subject: [PATCH] Don't register to receive IPC for hot windows Summary: These windows don't need to receive IPC until they're being used for something (i.e. after transitioning from hot window to composer, popout, etc) Test Plan: Run locally w/ hot windows shown, make sure that hot window doesn't receive IPC Reviewers: evan, spang, juan Reviewed By: juan Differential Revision: https://phab.nylas.com/D3780 --- src/flux/action-bridge.es6 | 11 ++++++++++- src/nylas-env.coffee | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/flux/action-bridge.es6 b/src/flux/action-bridge.es6 index 9e4d5e2ff..5d7047a46 100644 --- a/src/flux/action-bridge.es6 +++ b/src/flux/action-bridge.es6 @@ -54,7 +54,13 @@ class ActionBridge { NylasEnv.onBeforeUnload(this.onBeforeUnload); // Listen for action bridge messages from other windows - this.ipc.on('action-bridge-message', this.onIPCMessage); + if (NylasEnv.isEmptyWindow()) { + NylasEnv.onWindowPropsReceived(() => { + this.ipc.on('action-bridge-message', this.onIPCMessage); + }); + } else { + this.ipc.on('action-bridge-message', this.onIPCMessage); + } // Observe all global actions and re-broadcast them to other windows Actions.globalActions.forEach(name => { @@ -102,6 +108,9 @@ class ActionBridge { } onIPCMessage(event, initiatorId, name, json) { + if (NylasEnv.isEmptyWindow()) { + throw new Error("Empty windows shouldn't receive IPC messages"); + } // There's something very strange about IPC event handlers. The ReactRemoteParent // threw React exceptions when calling setState from an IPC callback, and the debugger // often refuses to stop at breakpoints immediately inside IPC callbacks. diff --git a/src/nylas-env.coffee b/src/nylas-env.coffee index 3c12eb81a..0976410be 100644 --- a/src/nylas-env.coffee +++ b/src/nylas-env.coffee @@ -355,6 +355,9 @@ class NylasEnvConstructor isMainWindow: -> !!@getLoadSettings().mainWindow + isEmptyWindow: -> + @getWindowType() is 'emptyWindow' + isWorkWindow: -> @getWindowType() is 'work'