Fix login/logout query cache not clearing

This commit is contained in:
Zoe Roux 2026-03-22 10:29:37 +01:00
parent 59a20a627c
commit f893d20e95
No known key found for this signature in database
3 changed files with 4 additions and 7 deletions

View File

@ -7,7 +7,6 @@ let hoverTimeout: NodeJS.Timeout | number;
export const useMobileHover = () => {
if (Platform.OS !== "web") return;
// biome-ignore lint/correctness/useHookAtTopLevel: const condition
useEffect(() => {
const enableHover = () => {
if (preventHover) return;

View File

@ -31,7 +31,6 @@ export const AccountProvider = ({ children }: { children: ReactNode }) => {
const router = useRouter();
if (Platform.OS !== "web") {
// biome-ignore lint/correctness/useHookAtTopLevel: static
useEffect(() => {
if (!ret.apiUrl) {
setTimeout(() => {
@ -76,12 +75,12 @@ export const AccountProvider = ({ children }: { children: ReactNode }) => {
updateAccount(nUser.id, nUser);
}, [user, userIsSuccess, userIsPlaceholder]);
const selectedId = ret.selectedAccount?.id;
const curId = selectedRef.current?.id;
useEffect(() => {
selectedId;
console.log("Selected user changed, new id: ", curId);
// if the user change account (or connect/disconnect), reset query cache.
queryClient.resetQueries();
}, [selectedId, queryClient]);
}, [curId, queryClient]);
return (
<AccountContext.Provider value={ret}>{children}</AccountContext.Provider>

View File

@ -50,7 +50,7 @@ export const useStoreValue = <T extends ZodType>(key: string, parser: T) => {
return readCookie(key, parser);
}
// biome-ignore lint/correctness/useHookAtTopLevel: constant
const [val] = useMMKVString(key);
const [val] = useMMKVString(key, storage);
if (val === undefined) return val;
return parser.parse(JSON.parse(val)) as z.infer<T>;
};
@ -71,7 +71,6 @@ export const readValue = <T extends ZodType>(key: string, parser: T) => {
export const useLocalSetting = <T extends string>(setting: string, def: T) => {
if (Platform.OS === "web" && typeof window === "undefined")
return [def as T, null!] as const;
// biome-ignore lint/correctness/useHookAtTopLevel: ssr
const [val, setter] = useMMKVString(`settings.${setting}`, storage);
return [(val ?? def) as T, setter] as const;
};