Fix active workspace deletion

This commit is contained in:
Gregory Schier
2025-01-03 20:50:18 -08:00
parent 31440eea76
commit 36cecb2d29
4 changed files with 18 additions and 16 deletions

View File

@@ -18,8 +18,6 @@ export function useRecentWorkspaces() {
[value, workspaces],
);
console.log("HELLO", {isLoading, value})
if (isLoading) return null;
return onlyValidIds;
@@ -29,18 +27,15 @@ export function useSubscribeRecentWorkspaces() {
useEffect(() => {
return jotaiStore.sub(activeWorkspaceIdAtom, async () => {
const activeWorkspaceId = jotaiStore.get(activeWorkspaceIdAtom);
console.log("AAA");
if (activeWorkspaceId == null) return;
const key = kvKey();
const recentIds = await getKeyValue<string[]>({ namespace, key, fallback });
console.log("BBB", recentIds, activeWorkspaceId);
if (recentIds[0] === activeWorkspaceId) return; // Short-circuit
const withoutActiveId = recentIds.filter((id) => id !== activeWorkspaceId);
const value = [activeWorkspaceId, ...withoutActiveId];
console.log("SET ACTIVE WORCENT", value);
await setKeyValue({ namespace, key, value });
});
}, []);