Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent verify from invalidating stores #2564

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this is needed? Is this due to the logOut? Shouldnt we simply call onClose on the logOut handleClickAction?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agalin920 This makes sure that it only closes the global accounts menu once the user has been successfully logged out instead of it immediately closing and then there's a brief moment where nothing happens while waiting for the api call to resolve.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm not sure if having a brief moment where nothing happens while it is open is any better than closing it and having a brief delay. At least having it close makes it seem the action went off as opposed to clicking it multiple times thinking it didnt go through.

}, [auth.valid]);

const handleClickAction = ([action, location]: ClickAction) => {
switch (action) {
case "openUrl":
Expand Down
2 changes: 1 addition & 1 deletion src/shell/components/load-instance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
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
Loading