From a2ff086dc66a0efbbd47d675f731af667b59e5d3 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 14 Nov 2023 15:55:42 -0600 Subject: [PATCH 1/2] Fix notification provider order, add comments --- src/App.native.tsx | 52 +++++++++++++++----------- src/App.web.tsx | 52 +++++++++++++++----------- src/state/queries/preferences/index.ts | 3 +- 3 files changed, 62 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..65f8e2cbc1 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, }) } @@ -91,6 +91,7 @@ export function useModerationOpts() { const {currentAccount} = useSession() const [opts, setOpts] = useState() const prefs = usePreferencesQuery() + console.log({preferences: prefs.data}) useEffect(() => { if (!prefs.data) { return From 1d7a6971664995e3a95aab609a4f468593d46405 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 14 Nov 2023 15:58:26 -0600 Subject: [PATCH 2/2] Remove log --- src/state/queries/preferences/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/state/queries/preferences/index.ts b/src/state/queries/preferences/index.ts index 65f8e2cbc1..7e16d4e9a4 100644 --- a/src/state/queries/preferences/index.ts +++ b/src/state/queries/preferences/index.ts @@ -91,7 +91,6 @@ export function useModerationOpts() { const {currentAccount} = useSession() const [opts, setOpts] = useState() const prefs = usePreferencesQuery() - console.log({preferences: prefs.data}) useEffect(() => { if (!prefs.data) { return