From 4c9006609c785f6ebb2239c05aecc021217d6f3f Mon Sep 17 00:00:00 2001 From: Chewbacca Date: Fri, 18 Nov 2022 10:25:24 -0500 Subject: [PATCH] Clear cache from React Query on change account --- app/soapbox/actions/auth.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/soapbox/actions/auth.ts b/app/soapbox/actions/auth.ts index 5bdf1f327..d588db80a 100644 --- a/app/soapbox/actions/auth.ts +++ b/app/soapbox/actions/auth.ts @@ -255,6 +255,10 @@ export const logOut = () => export const switchAccount = (accountId: string, background = false) => (dispatch: AppDispatch, getState: () => RootState) => { const account = getState().accounts.get(accountId); + // Clear all stored cache from React Query + queryClient.invalidateQueries(); + queryClient.clear(); + return dispatch({ type: SWITCH_ACCOUNT, account, background }); };