all state migrated to zustand, jotai removed

splash page now waits on state hydration from db
This commit is contained in:
austinried
2021-08-04 13:13:32 +09:00
parent 33dc0be02b
commit 706e57aa77
23 changed files with 427 additions and 660 deletions
+7 -2
View File
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'
import { Text, View } from 'react-native'
import RNFS from 'react-native-fs'
import paths from '@app/util/paths'
import { Store, useStore } from '@app/state/store'
async function mkdir(path: string): Promise<void> {
const exists = await RNFS.exists(path)
@@ -17,8 +18,11 @@ async function mkdir(path: string): Promise<void> {
return await RNFS.mkdir(path)
}
const selectHydrated = (store: Store) => store.hydrated
const SplashPage: React.FC<{}> = ({ children }) => {
const [ready, setReady] = useState(false)
const hydrated = useStore(selectHydrated)
const minSplashTime = new Promise(resolve => setTimeout(resolve, 1))
@@ -36,10 +40,11 @@ const SplashPage: React.FC<{}> = ({ children }) => {
})
})
if (!ready) {
if (ready && hydrated) {
return <View style={{ flex: 1 }}>{children}</View>
} else {
return <Text>Loading THE GOOD SHIT...</Text>
}
return <View style={{ flex: 1 }}>{children}</View>
}
export default SplashPage