Pull useQueryClient-dependent code down in App.native

This commit is contained in:
Dan Abramov
2024-03-21 23:38:55 +00:00
parent 17b014f4ae
commit 9e36c4abb0
+27 -21
View File
@@ -53,12 +53,10 @@ SplashScreen.preventAutoHideAsync()
function InnerApp() { function InnerApp() {
const {isInitialLoad, currentAccount} = useSession() const {isInitialLoad, currentAccount} = useSession()
const {resumeSession} = useSessionApi() const {resumeSession} = useSessionApi()
const queryClient = useQueryClient()
const theme = useColorModeTheme() const theme = useColorModeTheme()
const {_} = useLingui() const {_} = useLingui()
useIntentHandler() useIntentHandler()
useNotificationsListener(queryClient)
// init // init
useEffect(() => { useEffect(() => {
@@ -78,25 +76,27 @@ function InnerApp() {
// Resets the entire tree below when it changes: // Resets the entire tree below when it changes:
key={currentAccount?.did}> key={currentAccount?.did}>
<QueryProvider> <QueryProvider>
<StatsigProvider> <PushNotificationsListener>
<LabelDefsProvider> <StatsigProvider>
<LoggedOutViewProvider> <LabelDefsProvider>
<SelectedFeedProvider> <LoggedOutViewProvider>
<UnreadNotifsProvider> <SelectedFeedProvider>
<ThemeProvider theme={theme}> <UnreadNotifsProvider>
{/* All components should be within this provider */} <ThemeProvider theme={theme}>
<RootSiblingParent> {/* All components should be within this provider */}
<GestureHandlerRootView style={s.h100pct}> <RootSiblingParent>
<TestCtrls /> <GestureHandlerRootView style={s.h100pct}>
<Shell /> <TestCtrls />
</GestureHandlerRootView> <Shell />
</RootSiblingParent> </GestureHandlerRootView>
</ThemeProvider> </RootSiblingParent>
</UnreadNotifsProvider> </ThemeProvider>
</SelectedFeedProvider> </UnreadNotifsProvider>
</LoggedOutViewProvider> </SelectedFeedProvider>
</LabelDefsProvider> </LoggedOutViewProvider>
</StatsigProvider> </LabelDefsProvider>
</StatsigProvider>
</PushNotificationsListener>
</QueryProvider> </QueryProvider>
</React.Fragment> </React.Fragment>
</Splash> </Splash>
@@ -105,6 +105,12 @@ function InnerApp() {
) )
} }
function PushNotificationsListener({children}: {children: React.ReactNode}) {
const queryClient = useQueryClient()
useNotificationsListener(queryClient)
return children
}
function App() { function App() {
const [isReady, setReady] = useState(false) const [isReady, setReady] = useState(false)