mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-03-22 09:27:49 -04:00
Fix login/logout query cache not clearing
This commit is contained in:
parent
59a20a627c
commit
f893d20e95
@ -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;
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user