From 68767d597e82bf492ca02792182898cd5f64df21 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 14 Nov 2023 16:54:02 -0600 Subject: [PATCH] Fix notification provider order, add comments (#1905) * Fix notification provider order, add comments * Remove log --- src/App.native.tsx | 52 +++++++++++++++----------- src/App.web.tsx | 52 +++++++++++++++----------- src/state/queries/preferences/index.ts | 2 +- 3 files changed, 61 insertions(+), 45 deletions(-) diff --git a/src/App.native.tsx b/src/App.native.tsx index 5c4918f91d..60bce0578d 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -72,22 +72,28 @@ const InnerApp = observer(function AppImpl() { return null } + /* + * Session and initial state should be loaded prior to rendering below. + */ + return ( - - - - - {/* All components should be within this provider */} - - - - - - - - - - + + + + + + {/* All components should be within this provider */} + + + + + + + + + + + ) }) @@ -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 ( - - - - - - - + + + + + diff --git a/src/App.web.tsx b/src/App.web.tsx index 7bb6cb2568..b734aea087 100644 --- a/src/App.web.tsx +++ b/src/App.web.tsx @@ -60,22 +60,28 @@ const InnerApp = observer(function AppImpl() { return null } + /* + * Session and initial state should be loaded prior to rendering below. + */ + return ( - - - - - {/* All components should be within this provider */} - - - - - - - - - - + + + + + + {/* All components should be within this provider */} + + + + + + + + + + + ) }) @@ -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 ( - - - - - - - + + + + + diff --git a/src/state/queries/preferences/index.ts b/src/state/queries/preferences/index.ts index 4f10b01a6f..7e16d4e9a4 100644 --- a/src/state/queries/preferences/index.ts +++ b/src/state/queries/preferences/index.ts @@ -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() @@ -83,7 +84,6 @@ export function usePreferencesQuery() { } return preferences }, - enabled: hasSession, }) }