diff --git a/native/data/sqlite-context-provider.js b/native/data/sqlite-context-provider.js --- a/native/data/sqlite-context-provider.js +++ b/native/data/sqlite-context-provider.js @@ -8,6 +8,7 @@ import { fetchNewCookieFromNativeCredentials } from 'lib/utils/action-utils'; import { convertClientDBThreadInfosToRawThreadInfos } from 'lib/utils/thread-ops-utils'; +import { persistConfig } from '../redux/persist'; import { useSelector } from '../redux/redux-utils'; import { SQLiteContext } from './sqlite-context'; @@ -19,6 +20,9 @@ const [threadStoreLoaded, setThreadStoreLoaded] = React.useState( false, ); + const [messageStoreLoaded, setMessageStoreLoaded] = React.useState( + false, + ); const dispatch = useDispatch(); const rehydrateConcluded = useSelector( @@ -28,9 +32,12 @@ const urlPrefix = useSelector(state => state.urlPrefix); React.useEffect(() => { - if (threadStoreLoaded || !rehydrateConcluded) { + if ((threadStoreLoaded && messageStoreLoaded) || !rehydrateConcluded) { return; } + if (persistConfig.version < 31) { + setMessageStoreLoaded(true); + } (async () => { try { const threads = await global.CommCoreModule.getAllThreads(); @@ -52,13 +59,21 @@ setThreadStoreLoaded(true); } })(); - }, [threadStoreLoaded, urlPrefix, rehydrateConcluded, cookie, dispatch]); + }, [ + threadStoreLoaded, + urlPrefix, + rehydrateConcluded, + cookie, + dispatch, + messageStoreLoaded, + ]); const contextValue = React.useMemo( () => ({ threadStoreLoaded, + messageStoreLoaded, }), - [threadStoreLoaded], + [threadStoreLoaded, messageStoreLoaded], ); return ( diff --git a/native/data/sqlite-context.js b/native/data/sqlite-context.js --- a/native/data/sqlite-context.js +++ b/native/data/sqlite-context.js @@ -4,6 +4,7 @@ export type SQLiteContextType = { +threadStoreLoaded: boolean, + +messageStoreLoaded: boolean, }; const SQLiteContext: React.Context = React.createContext( diff --git a/native/navigation/app-navigator.react.js b/native/navigation/app-navigator.react.js --- a/native/navigation/app-navigator.react.js +++ b/native/navigation/app-navigator.react.js @@ -165,7 +165,9 @@ const localDatabaseContext: ?SQLiteContextType = React.useContext( SQLiteContext, ); - const storeLoadedFromLocalDatabase = localDatabaseContext?.threadStoreLoaded; + const storeLoadedFromLocalDatabase = + localDatabaseContext?.threadStoreLoaded && + localDatabaseContext?.messageStoreLoaded; const setNavStateInitialized = rootContext && rootContext.setNavStateInitialized; React.useEffect(() => { diff --git a/native/selectors/app-state-selectors.js b/native/selectors/app-state-selectors.js --- a/native/selectors/app-state-selectors.js +++ b/native/selectors/app-state-selectors.js @@ -9,7 +9,11 @@ const rehydrateConcluded = useSelector(state => !!state._persist?.rehydrated); const localDatabaseContext = React.useContext(SQLiteContext); - return rehydrateConcluded && !!localDatabaseContext?.threadStoreLoaded; + return ( + rehydrateConcluded && + !!localDatabaseContext?.threadStoreLoaded && + !!localDatabaseContext?.messageStoreLoaded + ); } export { usePersistedStateLoaded };