Skip to content

Commit

Permalink
Fix notification provider order, add comments (#1905)
Browse files Browse the repository at this point in the history
* Fix notification provider order, add comments

* Remove log
  • Loading branch information
estrattonbailey authored Nov 14, 2023
1 parent ab6e3f2 commit 68767d5
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 45 deletions.
52 changes: 30 additions & 22 deletions src/App.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,28 @@ const InnerApp = observer(function AppImpl() {
return null
}

/*
* Session and initial state should be loaded prior to rendering below.
*/

return (
<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>
</analytics.Provider>
</ThemeProvider>
<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>
</analytics.Provider>
</ThemeProvider>
</UnreadNotifsProvider>
)
})

Expand All @@ -102,19 +108,21 @@ function App() {
return null
}

/*
* NOTE: only nothing here can depend on other data or session state, since
* that is set up in the InnerApp component above.
*/
return (
<QueryClientProvider client={queryClient}>
<SessionProvider>
<ShellStateProvider>
<PrefsStateProvider>
<MutedThreadsProvider>
<UnreadNotifsProvider>
<InvitesStateProvider>
<ModalStateProvider>
<InnerApp />
</ModalStateProvider>
</InvitesStateProvider>
</UnreadNotifsProvider>
<InvitesStateProvider>
<ModalStateProvider>
<InnerApp />
</ModalStateProvider>
</InvitesStateProvider>
</MutedThreadsProvider>
</PrefsStateProvider>
</ShellStateProvider>
Expand Down
52 changes: 30 additions & 22 deletions src/App.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,28 @@ const InnerApp = observer(function AppImpl() {
return null
}

/*
* Session and initial state should be loaded prior to rendering below.
*/

return (
<ThemeProvider theme={colorMode}>
<analytics.Provider>
<RootStoreProvider value={rootStore}>
<I18nProvider i18n={i18n}>
{/* All components should be within this provider */}
<RootSiblingParent>
<SafeAreaProvider>
<Shell />
</SafeAreaProvider>
</RootSiblingParent>
</I18nProvider>
<ToastContainer />
</RootStoreProvider>
</analytics.Provider>
</ThemeProvider>
<UnreadNotifsProvider>
<ThemeProvider theme={colorMode}>
<analytics.Provider>
<RootStoreProvider value={rootStore}>
<I18nProvider i18n={i18n}>
{/* All components should be within this provider */}
<RootSiblingParent>
<SafeAreaProvider>
<Shell />
</SafeAreaProvider>
</RootSiblingParent>
</I18nProvider>
<ToastContainer />
</RootStoreProvider>
</analytics.Provider>
</ThemeProvider>
</UnreadNotifsProvider>
)
})

Expand All @@ -90,19 +96,21 @@ function App() {
return null
}

/*
* NOTE: only nothing here can depend on other data or session state, since
* that is set up in the InnerApp component above.
*/
return (
<QueryClientProvider client={queryClient}>
<SessionProvider>
<ShellStateProvider>
<PrefsStateProvider>
<MutedThreadsProvider>
<UnreadNotifsProvider>
<InvitesStateProvider>
<ModalStateProvider>
<InnerApp />
</ModalStateProvider>
</InvitesStateProvider>
</UnreadNotifsProvider>
<InvitesStateProvider>
<ModalStateProvider>
<InnerApp />
</ModalStateProvider>
</InvitesStateProvider>
</MutedThreadsProvider>
</PrefsStateProvider>
</ShellStateProvider>
Expand Down
2 changes: 1 addition & 1 deletion src/state/queries/preferences/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const usePreferencesQueryKey = ['getPreferences']
export function usePreferencesQuery() {
const {agent, hasSession} = useSession()
return useQuery({
enabled: hasSession,
queryKey: usePreferencesQueryKey,
queryFn: async () => {
const res = await agent.getPreferences()
Expand Down Expand Up @@ -83,7 +84,6 @@ export function usePreferencesQuery() {
}
return preferences
},
enabled: hasSession,
})
}

Expand Down

0 comments on commit 68767d5

Please sign in to comment.