From 8c39e30bb4db40f4736646cbdeeab3da61103736 Mon Sep 17 00:00:00 2001 From: Nar Cuenca Date: Thu, 22 Feb 2024 06:48:10 +0800 Subject: [PATCH 1/2] task: only refresh store data when auth validity changed --- src/shell/components/load-instance/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shell/components/load-instance/index.js b/src/shell/components/load-instance/index.js index c65b01fe74..83ed69a329 100644 --- a/src/shell/components/load-instance/index.js +++ b/src/shell/components/load-instance/index.js @@ -71,7 +71,7 @@ export default connect((state) => { props.dispatch(fetchFiles("views")); props.dispatch(fetchFiles("stylesheets")); props.dispatch(fetchFiles("scripts")); - }, [props.auth]); + }, [props.auth.valid]); useEffect(() => { if ( From c681ff26962edb475456d69b40c43b3d7f513e55 Mon Sep 17 00:00:00 2001 From: Nar Cuenca Date: Thu, 22 Feb 2024 07:24:29 +0800 Subject: [PATCH 2/2] task: close accounts menu on logout --- src/shell/components/GlobalAccountMenu/index.tsx | 9 ++++++++- src/shell/store/types.ts | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/shell/components/GlobalAccountMenu/index.tsx b/src/shell/components/GlobalAccountMenu/index.tsx index 33dc8988ae..90595001e9 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/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;