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
This commit is contained in:
Mark Hahnenberg 2017-01-25 12:22:43 -08:00
parent 6946bda2bd
commit 7bf8d18a02
2 changed files with 13 additions and 1 deletions

View file

@ -54,7 +54,13 @@ class ActionBridge {
NylasEnv.onBeforeUnload(this.onBeforeUnload);
// Listen for action bridge messages from other windows
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.

View file

@ -355,6 +355,9 @@ class NylasEnvConstructor
isMainWindow: ->
!!@getLoadSettings().mainWindow
isEmptyWindow: ->
@getWindowType() is 'emptyWindow'
isWorkWindow: ->
@getWindowType() is 'work'