mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 15:29:15 +01:00
all state migrated to zustand, jotai removed
splash page now waits on state hydration from db
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user