Skip to content

Commit

Permalink
Fix notification provider order, add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey committed Nov 14, 2023
1 parent ab6e3f2 commit a2ff086
Show file tree
Hide file tree
Showing 3 changed files with 62 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
3 changes: 2 additions & 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,14 +84,14 @@ export function usePreferencesQuery() {
}
return preferences
},
enabled: hasSession,
})
}

export function useModerationOpts() {
const {currentAccount} = useSession()
const [opts, setOpts] = useState<ModerationOpts | undefined>()
const prefs = usePreferencesQuery()
console.log({preferences: prefs.data})
useEffect(() => {
if (!prefs.data) {
return
Expand Down

0 comments on commit a2ff086

Please sign in to comment.