Merge branch 'clear-cache' into 'develop'
Clear cache from React Query on logout See merge request soapbox-pub/soapbox!1912
This commit is contained in:
commit
39ba34983f
|
@ -16,6 +16,7 @@ import { obtainOAuthToken, revokeOAuthToken } from 'soapbox/actions/oauth';
|
||||||
import { startOnboarding } from 'soapbox/actions/onboarding';
|
import { startOnboarding } from 'soapbox/actions/onboarding';
|
||||||
import snackbar from 'soapbox/actions/snackbar';
|
import snackbar from 'soapbox/actions/snackbar';
|
||||||
import { custom } from 'soapbox/custom';
|
import { custom } from 'soapbox/custom';
|
||||||
|
import { queryClient } from 'soapbox/queries/client';
|
||||||
import KVStore from 'soapbox/storage/kv-store';
|
import KVStore from 'soapbox/storage/kv-store';
|
||||||
import { getLoggedInAccount, parseBaseURL } from 'soapbox/utils/auth';
|
import { getLoggedInAccount, parseBaseURL } from 'soapbox/utils/auth';
|
||||||
import sourceCode from 'soapbox/utils/code';
|
import sourceCode from 'soapbox/utils/code';
|
||||||
|
@ -239,15 +240,25 @@ export const logOut = () =>
|
||||||
token: state.auth.getIn(['users', account.url, 'access_token']),
|
token: state.auth.getIn(['users', account.url, 'access_token']),
|
||||||
};
|
};
|
||||||
|
|
||||||
return dispatch(revokeOAuthToken(params)).finally(() => {
|
return dispatch(revokeOAuthToken(params))
|
||||||
dispatch({ type: AUTH_LOGGED_OUT, account, standalone });
|
.finally(() => {
|
||||||
return dispatch(snackbar.success(messages.loggedOut));
|
// Clear all stored cache from React Query
|
||||||
});
|
queryClient.invalidateQueries();
|
||||||
|
queryClient.clear();
|
||||||
|
|
||||||
|
dispatch({ type: AUTH_LOGGED_OUT, account, standalone });
|
||||||
|
|
||||||
|
return dispatch(snackbar.success(messages.loggedOut));
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const switchAccount = (accountId: string, background = false) =>
|
export const switchAccount = (accountId: string, background = false) =>
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
const account = getState().accounts.get(accountId);
|
const account = getState().accounts.get(accountId);
|
||||||
|
// Clear all stored cache from React Query
|
||||||
|
queryClient.invalidateQueries();
|
||||||
|
queryClient.clear();
|
||||||
|
|
||||||
return dispatch({ type: SWITCH_ACCOUNT, account, background });
|
return dispatch({ type: SWITCH_ACCOUNT, account, background });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue