Remove deprecated models and mobx usage (react-query refactor) (#1934)

* Update login page to use service query

* Update modal to use session instead of store

* Move image sizes cache off store

* Update settings to no longer use store

* Update link-meta fetch to use agent instead of rootstore

* Remove deprecated resolveName()

* Delete deprecated link-metas cache

* Delete deprecated posts cache

* Delete all remaining mobx models, including the root store

* Strip out unused mobx observer wrappers
This commit is contained in:
Paul Frazee 2023-11-16 12:53:43 -08:00 committed by GitHub
parent e637798e05
commit 54faa7e176
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
81 changed files with 1084 additions and 1941 deletions

View file

@ -5,7 +5,6 @@ import React, {useState, useEffect} from 'react'
import {RootSiblingParent} from 'react-native-root-siblings'
import * as SplashScreen from 'expo-splash-screen'
import {GestureHandlerRootView} from 'react-native-gesture-handler'
import {observer} from 'mobx-react-lite'
import {QueryClientProvider} from '@tanstack/react-query'
import 'view/icons'
@ -16,7 +15,6 @@ import {listenSessionDropped} from './state/events'
import {useColorMode} from 'state/shell'
import {ThemeProvider} from 'lib/ThemeContext'
import {s} from 'lib/styles'
import {RootStoreModel, setupState, RootStoreProvider} from './state'
import {Shell} from 'view/shell'
import * as notifications from 'lib/notifications/notifications'
import * as analytics from 'lib/analytics/analytics'
@ -44,21 +42,12 @@ i18n.activate('en')
SplashScreen.preventAutoHideAsync()
const InnerApp = observer(function AppImpl() {
function InnerApp() {
const colorMode = useColorMode()
const {isInitialLoad} = useSession()
const {resumeSession} = useSessionApi()
const [rootStore, setRootStore] = useState<RootStoreModel | undefined>(
undefined,
)
// init
useEffect(() => {
setupState().then(store => {
setRootStore(store)
})
}, [])
useEffect(() => {
initReminders()
analytics.init()
@ -72,7 +61,7 @@ const InnerApp = observer(function AppImpl() {
}, [resumeSession])
// show nothing prior to init
if (!rootStore || isInitialLoad) {
if (isInitialLoad) {
// TODO add a loading state
return null
}
@ -85,22 +74,20 @@ const InnerApp = observer(function AppImpl() {
<UnreadNotifsProvider>
<ThemeProvider theme={colorMode}>
<analytics.Provider>
<RootStoreProvider value={rootStore}>
<I18nProvider i18n={i18n}>
{/* All components should be within this provider */}
<RootSiblingParent>
<GestureHandlerRootView style={s.h100pct}>
<TestCtrls />
<Shell />
</GestureHandlerRootView>
</RootSiblingParent>
</I18nProvider>
</RootStoreProvider>
<I18nProvider i18n={i18n}>
{/* All components should be within this provider */}
<RootSiblingParent>
<GestureHandlerRootView style={s.h100pct}>
<TestCtrls />
<Shell />
</GestureHandlerRootView>
</RootSiblingParent>
</I18nProvider>
</analytics.Provider>
</ThemeProvider>
</UnreadNotifsProvider>
)
})
}
function App() {
const [isReady, setReady] = useState(false)