Skip to content

Commit

Permalink
🔧 worxpace Reset tree states when workspace changes (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
steeeee0223 authored Dec 6, 2024
2 parents 344a92d + 65a3d80 commit 7e5ccfd
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
ResizablePanel,
ResizablePanelGroup,
} from "@swy/ui/shadcn";
import { useModal } from "@swy/ui/shared";
import { useModal, useTree } from "@swy/ui/shared";

import {
useDocuments,
Expand All @@ -45,6 +45,7 @@ const WorkspaceLayout: React.FC<WorkspaceLayoutProps> = ({
const { setClose } = useModal();
const { clerkId, accountId, workspaceId, ...platform } = usePlatform();
const { activeWorkspace, select } = useWorkspace();
const setNodes = useTree((state) => state.set);
/** Clerk */
const { signOut } = useAuth();
const { user } = useUser();
Expand Down Expand Up @@ -170,12 +171,14 @@ const WorkspaceLayout: React.FC<WorkspaceLayoutProps> = ({
workspaceHandlers: {
onSelect: (id) => {
platform.update((prev) => ({ ...prev, workspaceId: id }));
setNodes([]);
store.reset();
router.push(`/workspace/${id}`);
},
onCreateWorkspace: () => router.push("/onboarding"),
onLogout: () => {
platform.reset();
setNodes([]);
store.reset();
void signOut(() => router.push("/select-role"));
},
Expand Down

0 comments on commit 7e5ccfd

Please sign in to comment.