mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-22 16:09:14 +08:00
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:
parent
6946bda2bd
commit
7bf8d18a02
2 changed files with 13 additions and 1 deletions
|
@ -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.
|
||||
|
|
|
@ -355,6 +355,9 @@ class NylasEnvConstructor
|
|||
isMainWindow: ->
|
||||
!!@getLoadSettings().mainWindow
|
||||
|
||||
isEmptyWindow: ->
|
||||
@getWindowType() is 'emptyWindow'
|
||||
|
||||
isWorkWindow: ->
|
||||
@getWindowType() is 'work'
|
||||
|
||||
|
|
Loading…
Reference in a new issue