diff --git a/src/app.tsx b/src/app.tsx index 8d7b031..54fbf8f 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -5,15 +5,13 @@ import { SafeAreaProvider } from 'react-native-safe-area-context'; import { RealmProvider } from '@realm/react'; import { Provider } from 'react-redux'; import { PersistGate } from 'redux-persist/integration/react'; -import { openDocumentTree } from 'react-native-scoped-storage'; import type {} from 'redux-thunk/extend-redux'; import { lightTheme, darkTheme } from './theme'; import { Meme, Tag } from './database'; import NavigationContainer from './navigation'; -import { store, persistor, updateStorageUri, validateSettings } from './state'; +import { store, persistor, validateSettings } from './state'; import { LoadingView } from './components'; import { Welcome } from './screens'; -import { noOp } from './utilities'; const App = () => { const [showWelcome, setShowWelcome] = useState(false); @@ -32,7 +30,6 @@ const App = () => { useEffect(() => { const subscription = AppState.addEventListener('change', async state => { if (state !== 'active') return; - await store.dispatch(validateSettings()); const { settings } = store.getState(); if (!settings.storageUri) { @@ -55,18 +52,7 @@ const App = () => { barStyle={isDarkMode ? 'light-content' : 'dark-content'} backgroundColor={theme.colors.background} /> - {showWelcome ? ( - { - const uri = await openDocumentTree(true).catch(noOp); - if (!uri) return; - await store.dispatch(updateStorageUri(uri.uri)); - setShowWelcome(false); - }} - /> - ) : ( - - )} + {showWelcome ? : } diff --git a/src/screens/welcome.tsx b/src/screens/welcome.tsx index 96e1706..2cec998 100644 --- a/src/screens/welcome.tsx +++ b/src/screens/welcome.tsx @@ -1,11 +1,21 @@ import React from 'react'; import { Button, Text } from 'react-native-paper'; +import { useDispatch } from 'react-redux'; +import { openDocumentTree } from 'react-native-scoped-storage'; import { PaddedView } from '../components'; import styles from '../styles'; +import { noOp } from '../utilities'; +import { updateStorageUri } from '../state'; + +const Welcome = () => { + const dispatch = useDispatch(); + + const selectStorageLocation = async () => { + const uri = await openDocumentTree(true).catch(noOp); + if (!uri) return; + await dispatch(updateStorageUri(uri.uri)); + }; -const Welcome = (properties: { - selectStorageLocation: () => Promise; -}) => { return (