Skip to content

Commit

Permalink
handle the view mode properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Salam-Dalloul committed Aug 8, 2024
1 parent 2ceb605 commit f7a4efb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,12 @@ const Header = ({
if (Object.keys(workspaces).length >= 2) {
const selectedWorkspaces = new Set(Object.keys(workspaces).slice(0, 2));
setSelectedWorkspacesIds(selectedWorkspaces);
setViewMode(ViewMode.Compare);
} else {
setShowModal(true);
}
} else {
const selectedWorkspaces = new Set(Object.keys(workspaces).slice(0, 1));
setSelectedWorkspacesIds(selectedWorkspaces);
setViewMode(ViewMode.Default);
setCurrentWorkspace(Array.from(selectedWorkspaces)[0]);
}
};
Expand All @@ -124,20 +122,18 @@ const Header = ({
const onClose = () => {
setShowModal(false);
const newIndex = Array.from(selectedWorkspacesIds).length >= 2 ? 1 : 0;
if (Object.keys(workspaces).length > 1) {
setActive(newIndex);
setViewMode(ViewMode.Compare);
} else {
setActive(0);
setViewMode(ViewMode.Default);
}
setActive(newIndex);
};

useEffect(() => {
const newIndex = Array.from(selectedWorkspacesIds).length >= 2 ? 1 : 0;
setActive(newIndex);
if (newIndex === 0) {
setViewMode(ViewMode.Default);
} else {
setViewMode(ViewMode.Compare);
}
}, [selectedWorkspacesIds]);

return (
<>
<AppBar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ function WorkspaceComponent({ sidebarOpen }) {
justifyContent: "space-between",
backgroundColor: "transparent !important",
}}
// disabled={Array.from(selectedWorkspacesIds).includes(workspace.id)}
>
<Box display="flex" alignItems="center" gap=".5rem">
<Box
Expand Down

0 comments on commit f7a4efb

Please sign in to comment.