Skip to content

Commit

Permalink
task: close accounts menu on logout
Browse files Browse the repository at this point in the history
  • Loading branch information
finnar-bin committed Feb 21, 2024
1 parent 8c39e30 commit c681ff2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/shell/components/GlobalAccountMenu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, useMemo } from "react";
import { FC, useEffect, useMemo } from "react";
import { useDispatch, useSelector } from "react-redux";

import {
Expand Down Expand Up @@ -36,6 +36,7 @@ export const GlobalAccountMenu: FC<GlobalAccountMenuProps> = ({
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(() => {
Expand All @@ -44,6 +45,12 @@ export const GlobalAccountMenu: FC<GlobalAccountMenuProps> = ({

const dispatch = useDispatch();

useEffect(() => {
if (!auth.valid) {
onClose();
}
}, [auth.valid]);

const handleClickAction = ([action, location]: ClickAction) => {
switch (action) {
case "openUrl":
Expand Down
6 changes: 5 additions & 1 deletion src/shell/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c681ff2

Please sign in to comment.