mirror of https://github.com/tooot-app/app
Persist storage working
This commit is contained in:
parent
40266b8ce3
commit
1ad67e67ac
2
App.tsx
2
App.tsx
|
@ -3,7 +3,7 @@ import { QueryCache, ReactQueryCacheProvider, setConsole } from 'react-query'
|
|||
import { Provider } from 'react-redux'
|
||||
|
||||
import { Index } from 'src/Index'
|
||||
import store from 'src/store'
|
||||
import { store } from 'src/store'
|
||||
|
||||
const queryCache = new QueryCache()
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import store, { RootState } from 'src/store'
|
||||
import { store, RootState } from 'src/store'
|
||||
import ky from 'ky'
|
||||
|
||||
const client = async ({
|
||||
|
|
|
@ -14,7 +14,7 @@ import { Feather } from '@expo/vector-icons'
|
|||
|
||||
import client from 'src/api/client'
|
||||
import { getLocalAccountId } from 'src/utils/slices/instancesSlice'
|
||||
import store from 'src/store'
|
||||
import {store} from 'src/store'
|
||||
|
||||
const fireMutation = async ({
|
||||
id,
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
getLocalAccountId,
|
||||
getLocalUrl
|
||||
} from 'src/utils/slices/instancesSlice'
|
||||
import store from 'src/store'
|
||||
import {store} from 'src/store'
|
||||
|
||||
const fireMutation = async ({
|
||||
id,
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
import React from 'react'
|
||||
import { View } from 'react-native'
|
||||
import store from 'src/store'
|
||||
import { getLocalRegistered } from 'src/utils/slices/instancesSlice'
|
||||
import { useSelector } from 'react-redux'
|
||||
|
||||
import { RootState } from 'src/store'
|
||||
|
||||
import Login from './Root/Login'
|
||||
|
||||
const ScreenMeRoot: React.FC = () => {
|
||||
const localRegistered = getLocalRegistered(store.getState())
|
||||
const localRegistered = useSelector(
|
||||
(state: RootState) => state.instances.local.url
|
||||
)
|
||||
|
||||
return <View>{localRegistered ? <></> : <Login />}</View>
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import { SafeAreaView } from 'react-native-safe-area-context'
|
|||
import { createNativeStackNavigator } from 'react-native-screens/native-stack'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
|
||||
import store from 'src/store'
|
||||
import { store } from 'src/store'
|
||||
import PostMain from './Compose/PostMain'
|
||||
import client from 'src/api/client'
|
||||
import { getLocalAccountPreferences } from 'src/utils/slices/instancesSlice'
|
||||
|
|
14
src/store.ts
14
src/store.ts
|
@ -1,13 +1,23 @@
|
|||
import { configureStore } from '@reduxjs/toolkit'
|
||||
import { persistReducer, persistStore } from 'redux-persist'
|
||||
import createSecureStore from 'redux-persist-expo-securestore'
|
||||
|
||||
import instancesSlice from 'src/utils/slices/instancesSlice'
|
||||
|
||||
const secureStorage = createSecureStore()
|
||||
|
||||
const instancesPersistConfig = {
|
||||
key: 'instances',
|
||||
storage: secureStorage
|
||||
}
|
||||
|
||||
const store = configureStore({
|
||||
reducer: {
|
||||
instances: instancesSlice
|
||||
instances: persistReducer(instancesPersistConfig, instancesSlice)
|
||||
}
|
||||
})
|
||||
|
||||
export default store
|
||||
let persistor = persistStore(store)
|
||||
|
||||
export { store, persistor }
|
||||
export type RootState = ReturnType<typeof store.getState>
|
||||
|
|
Loading…
Reference in New Issue