From 2f082f8beb608394dc4912a67c6926cd646fa9a7 Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Mon, 3 Apr 2017 16:44:01 -0700 Subject: [PATCH] [client-app] re-setup IdentityStore in new window Summary: Before this patch, the IdentityStore would initialize in our empty hot window. However, hot windows don't receive any `action-bridge-message`s, which include DB updates. Since the hot window loads first, it was with a stale verison of the Identity. The main window fetches a fresh identity, but that fresh update failed to get to new composers because the hot window wasn't listening to changes to the DB. This makes it such that the IdentityStore properly boots up when the window props change. Test Plan: manual Reviewers: halla, juan Reviewed By: juan Differential Revision: https://phab.nylas.com/D4327 --- packages/client-app/src/flux/stores/identity-store.es6 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/client-app/src/flux/stores/identity-store.es6 b/packages/client-app/src/flux/stores/identity-store.es6 index 111b4d639..13f6cff1a 100644 --- a/packages/client-app/src/flux/stores/identity-store.es6 +++ b/packages/client-app/src/flux/stores/identity-store.es6 @@ -22,6 +22,14 @@ class IdentityStore extends NylasStore { } async activate() { + if (NylasEnv.isEmptyWindow()) { + NylasEnv.onWindowPropsReceived(() => { + this.deactivate(); + this.activate(); + }) + return + } + NylasEnv.config.onDidChange('env', this._onEnvChanged); this._onEnvChanged(); @@ -37,7 +45,7 @@ class IdentityStore extends NylasStore { } deactivate() { - this._disp.dispose(); + if (this._disp) this._disp.dispose(); this.stopListeningToAll() }