Files
yaak-mountain-loop/src-web/hooks/useActiveWorkspaceChangedToast.tsx
Gregory Schier b4a1c418bb Run oxfmt across repo, add format script and docs
Add .oxfmtignore to skip generated bindings and wasm-pack output.
Add npm format script, update DEVELOPMENT.md for Vite+ toolchain,
and format all non-generated files with oxfmt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 10:15:49 -07:00

32 lines
993 B
TypeScript

import { useAtomValue } from "jotai";
import { useEffect, useState } from "react";
import { InlineCode } from "../components/core/InlineCode";
import { showToast } from "../lib/toast";
import { activeWorkspaceAtom } from "./useActiveWorkspace";
export function useActiveWorkspaceChangedToast() {
const activeWorkspace = useAtomValue(activeWorkspaceAtom);
const [id, setId] = useState<string | null>(activeWorkspace?.id ?? null);
useEffect(() => {
// Early return if same or invalid active workspace
if (id === activeWorkspace?.id || activeWorkspace == null) return;
setId(activeWorkspace?.id ?? null);
// Don't notify on the first load
if (id === null) return;
showToast({
id: `workspace-changed-${activeWorkspace.id}`,
timeout: 3000,
message: (
<>
Activated workspace{" "}
<InlineCode className="whitespace-nowrap">{activeWorkspace.name}</InlineCode>
</>
),
});
}, [activeWorkspace, id]);
}