Skip to content

Commit b40cb54

Browse files
committed
Use workspaces for sidebar auto detect
1 parent a9e5d01 commit b40cb54

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

apps/array/src/renderer/features/sidebar/components/MainSidebar.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
import { useTasks } from "@features/tasks/hooks/useTasks";
1+
import { useWorkspaceStore } from "@features/workspace/stores/workspaceStore";
22
import { Box } from "@radix-ui/themes";
33
import { useEffect } from "react";
44
import { useSidebarStore } from "../stores/sidebarStore";
55
import { Sidebar, SidebarContent } from "./index";
66

77
export function MainSidebar() {
8-
const { data: tasks = [], isFetched } = useTasks();
8+
const workspaces = useWorkspaceStore((state) => state.workspaces);
9+
const isLoaded = useWorkspaceStore((state) => state.isLoaded);
910
const setOpenAuto = useSidebarStore((state) => state.setOpenAuto);
1011

1112
useEffect(() => {
12-
if (isFetched) {
13-
setOpenAuto(tasks.length > 0);
13+
if (isLoaded) {
14+
const workspaceCount = Object.keys(workspaces).length;
15+
setOpenAuto(workspaceCount > 0);
1416
}
15-
}, [isFetched, tasks.length, setOpenAuto]);
17+
}, [isLoaded, workspaces, setOpenAuto]);
1618

1719
return (
1820
<Box flexShrink="0" style={{ flexShrink: 0 }}>

0 commit comments

Comments
 (0)