diff --git a/front/apps/web/src/pages/_app.tsx b/front/apps/web/src/pages/_app.tsx index c444af2d..a606bcbd 100755 --- a/front/apps/web/src/pages/_app.tsx +++ b/front/apps/web/src/pages/_app.tsx @@ -139,7 +139,7 @@ const WithLayout = ({ Component, ...props }: { Component: ComponentType }) => { return ( + } diff --git a/front/packages/models/src/accounts.tsx b/front/packages/models/src/accounts.tsx index 06838193..b9f93d45 100644 --- a/front/packages/models/src/accounts.tsx +++ b/front/packages/models/src/accounts.tsx @@ -94,7 +94,7 @@ export const AccountProvider = ({ error: ssrError || null, loading: false, retry: () => { - queryClient.invalidateQueries({ queryKey: ["auth", "me"] }); + queryClient.resetQueries({ queryKey: ["auth", "me"] }); }, }} > @@ -144,7 +144,7 @@ export const AccountProvider = ({ // if the user change account (or connect/disconnect), reset query cache. if (selected?.id !== oldSelectedId.current) { initialSsrError.current = undefined; - queryClient.invalidateQueries(); + queryClient.resetQueries(); } oldSelectedId.current = selected?.id; diff --git a/front/packages/ui/src/errors/error.tsx b/front/packages/ui/src/errors/error.tsx index 2938a681..e08e7028 100644 --- a/front/packages/ui/src/errors/error.tsx +++ b/front/packages/ui/src/errors/error.tsx @@ -18,9 +18,9 @@ * along with Kyoo. If not, see . */ -import { KyooErrors } from "@kyoo/models"; +import { KyooErrors, useAccount } from "@kyoo/models"; import { P } from "@kyoo/primitives"; -import { ReactElement, createContext, useContext, useLayoutEffect, useState } from "react"; +import { ReactElement, createContext, useContext, useEffect, useLayoutEffect, useState } from "react"; import { View } from "react-native"; import { useYoshiki } from "yoshiki/native"; import { PermissionError } from "./unauthorized"; @@ -60,8 +60,15 @@ export const ErrorView = ({ }; const ErrorCtx = createContext<(val: KyooErrors | null) => void>(null!); + export const ErrorContext = ({ children }: { children: ReactElement }) => { const [error, setError] = useState(null); + const account = useAccount(); + + useEffect(() => { + setError(null); + }, [account, children]); + if (error && (error.status === 401 || error.status === 403)) return ; if (error) return ;