diff --git a/app/mattermost.js b/app/mattermost.js index 738c3b576..f89a654e0 100644 --- a/app/mattermost.js +++ b/app/mattermost.js @@ -48,16 +48,17 @@ const init = async () => { } }; -const launchApp = async (credentials) => { +const launchApp = (credentials) => { telemetry.start([ 'start:select_server_screen', 'start:channel_screen', ]); if (credentials) { - await waitForHydration(store); - store.dispatch(loadMe()); - resetToChannel({skipMetrics: true}); + waitForHydration(store, () => { + store.dispatch(loadMe()); + resetToChannel({skipMetrics: true}); + }); } else { resetToSelectServer(emmProvider.allowOtherServers); } diff --git a/app/store/utils.js b/app/store/utils.js index bd94cc917..192b70826 100644 --- a/app/store/utils.js +++ b/app/store/utils.js @@ -42,23 +42,14 @@ export function transformSet(incoming, setTransforms, toStorage = true) { } export function waitForHydration(store, callback) { - let unsubscribeFromStore; - return new Promise((resolve) => { - if (__DEV__) { - // when in DEV mode resetting the app can get into a white screen - resolve(); - return; - } - const subscription = () => { - if (store.getState().views.root.hydrationComplete) { - unsubscribeFromStore(); - if (callback && typeof callback === 'function') { - callback(); - } - resolve(); + const subscription = () => { + if (store.getState().views.root.hydrationComplete) { + unsubscribeFromStore(); + if (callback && typeof callback === 'function') { + callback(); } - }; + } + }; - unsubscribeFromStore = store.subscribe(subscription); - }); + const unsubscribeFromStore = store.subscribe(subscription); } \ No newline at end of file