From e960d37cdc91676154c3d74b7371942ad8aa6f68 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Sat, 23 Mar 2019 11:07:43 -0300 Subject: [PATCH] MM-14459 Ensure hydrationComplete is set to true when resetting the cache and logging out (#2664) --- app/mattermost.js | 4 ++-- app/store/index.js | 7 ++++++- app/store/middleware.js | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/mattermost.js b/app/mattermost.js index 7b282770e..bb8aaf3ac 100644 --- a/app/mattermost.js +++ b/app/mattermost.js @@ -91,7 +91,7 @@ const initializeModules = () => { EventEmitter.on(NavigationTypes.RESTART_APP, restartApp); EventEmitter.on(General.SERVER_VERSION_CHANGED, handleServerVersionChanged); EventEmitter.on(General.CONFIG_CHANGED, handleConfigChanged); - EventEmitter.on(General.SWITCH_TO_DEFAULT_CHANNEL, handleSwithToDefaultChannel); + EventEmitter.on(General.SWITCH_TO_DEFAULT_CHANNEL, handleSwitchToDefaultChannel); Dimensions.addEventListener('change', handleOrientationChange); mattermostManaged.addEventListener('managedConfigDidChange', () => { handleManagedConfig(true); @@ -338,7 +338,7 @@ const handleAuthentication = async (vendor) => { return true; }; -const handleSwithToDefaultChannel = (teamId) => { +const handleSwitchToDefaultChannel = (teamId) => { store.dispatch(selectDefaultChannel(teamId)); }; diff --git a/app/store/index.js b/app/store/index.js index 3cb203f3e..5a031c704 100644 --- a/app/store/index.js +++ b/app/store/index.js @@ -145,7 +145,6 @@ export default function configureAppStore(initialState) { const persistor = persistStore(store, {storage: AsyncStorage, ...options}, () => { store.dispatch({ type: General.STORE_REHYDRATION_COMPLETE, - complete: true, }); }); @@ -204,6 +203,9 @@ export default function configureAppStore(initialState) { type: General.OFFLINE_STORE_RESET, data: initialState, }, + { + type: General.STORE_REHYDRATION_COMPLETE, + }, { type: ViewTypes.SERVER_URL_CHANGED, serverUrl: state.entities.general.credentials.url || state.views.selectServer.serverUrl, @@ -256,6 +258,9 @@ export default function configureAppStore(initialState) { type: GeneralTypes.RECEIVED_SERVER_VERSION, data: state.entities.general.serverVersion, }, + { + type: General.STORE_REHYDRATION_COMPLETE, + }, ], 'BATCH_FOR_RESTART')); setTimeout(() => { diff --git a/app/store/middleware.js b/app/store/middleware.js index 88550369f..afbde25da 100644 --- a/app/store/middleware.js +++ b/app/store/middleware.js @@ -166,6 +166,9 @@ function resetStateForNewVersion(action) { thread: { drafts: threadDrafts, }, + root: { + hydrationComplete: true, + }, selectServer, recentEmojis, },