From 2fb315239ffac5ff6d17d239f4efba8f579e8c65 Mon Sep 17 00:00:00 2001 From: Nar Cuenca <28705606+theofficialnar@users.noreply.github.com> Date: Thu, 29 Feb 2024 03:43:04 +0800 Subject: [PATCH] Prevent verify from invalidating stores (#2564) * task: only refresh store data when auth validity changed * task: close accounts menu on logout --- src/shell/components/GlobalAccountMenu/index.tsx | 9 ++++++++- src/shell/components/load-instance/index.js | 2 +- src/shell/store/types.ts | 6 +++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/shell/components/GlobalAccountMenu/index.tsx b/src/shell/components/GlobalAccountMenu/index.tsx index db95d57b98..9255000d83 100644 --- a/src/shell/components/GlobalAccountMenu/index.tsx +++ b/src/shell/components/GlobalAccountMenu/index.tsx @@ -1,4 +1,4 @@ -import { FC, useMemo } from "react"; +import { FC, useEffect, useMemo } from "react"; import { useDispatch, useSelector } from "react-redux"; import { @@ -36,6 +36,7 @@ export const GlobalAccountMenu: FC = ({ onShowDocsMenu, }) => { const user: User = useSelector((state: AppState) => state.user); + const auth = useSelector((state: AppState) => state.auth); const { data: roles, isLoading: isLoadingRoles } = useGetUsersRolesQuery(); const userRole = useMemo(() => { @@ -44,6 +45,12 @@ export const GlobalAccountMenu: FC = ({ const dispatch = useDispatch(); + useEffect(() => { + if (!auth.valid) { + onClose(); + } + }, [auth.valid]); + const handleClickAction = ([action, location]: ClickAction) => { switch (action) { case "openUrl": diff --git a/src/shell/components/load-instance/index.js b/src/shell/components/load-instance/index.js index 7fb28517e5..48720282b2 100644 --- a/src/shell/components/load-instance/index.js +++ b/src/shell/components/load-instance/index.js @@ -75,7 +75,7 @@ export default connect((state) => { props.dispatch(fetchFiles("views")); props.dispatch(fetchFiles("stylesheets")); props.dispatch(fetchFiles("scripts")); - }, [props.auth]); + }, [props.auth.valid]); useEffect(() => { if ( diff --git a/src/shell/store/types.ts b/src/shell/store/types.ts index 6ddb5d447d..b3c678b2e7 100644 --- a/src/shell/store/types.ts +++ b/src/shell/store/types.ts @@ -16,7 +16,11 @@ export type AppState = { frames: any; installed: InstalledApp[]; }; - auth: any; + auth: { + checking: boolean; + valid: boolean; + sessionEnding: boolean; + }; user: any; users: any; releases: any;