Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
Make team-spaces capability reactive and clear workspace/tree state on sign-out
Gabriel Steindcfe80c73bb0
diff --git a/src/hooks/useTeamSpacesCapability.ts b/src/hooks/useTeamSpacesCapability.tsindex fe344cb4a..82527b172 100644--- a/src/hooks/useTeamSpacesCapability.ts+++ b/src/hooks/useTeamSpacesCapability.ts@@ -1,4 +1,9 @@+import { useSyncExternalStore } from "react";import { useSpaces } from "../stores/noteStore";+import {+ readTeamSpacesCapability,+ subscribeTeamSpacesCapability,+} from "../lib/teamSpacesCapability";/** Dev override forcing the TEAM SPACES section on without a server probe. */function hasTeamSpacesDevOverride(): boolean {@@ -12,9 +17,8 @@ function hasTeamSpacesDevOverride(): boolean {*/export function useTeamSpacesCapability(): boolean {const spaces = useSpaces();+ const capability = useSyncExternalStore(subscribeTeamSpacesCapability, readTeamSpacesCapability);return (- hasTeamSpacesDevOverride() ||- localStorage.getItem("teamSpacesCapability") === "true" ||- spaces.some((space) => space.kind === "team")+ hasTeamSpacesDevOverride() || capability || spaces.some((space) => space.kind === "team"));}diff --git a/src/lib/teamSpacesCapability.ts b/src/lib/teamSpacesCapability.tsnew file mode 100644index 000000000..3702b0062--- /dev/null+++ b/src/lib/teamSpacesCapability.ts@@ -0,0 +1,27 @@+// Reactive view over the localStorage team-spaces capability flag: the sync+// pass probes the server and writes the flag, and mounted consumers+// (useTeamSpacesCapability) must re-render when it flips — same-window flips+// notify subscribers directly, cross-window ones ride the storage event.+const CAPABILITY_KEY = "teamSpacesCapability";++const subscribers = new Set<() => void>();++export function readTeamSpacesCapability(): boolean {+ return localStorage.getItem(CAPABILITY_KEY) === "true";+}++export function notifyTeamSpacesCapabilityChanged(): void {+ subscribers.forEach((notify) => notify());+}++export function subscribeTeamSpacesCapability(onChange: () => void): () => void {+ subscribers.add(onChange);+ const onStorage = (e: StorageEvent) => {+ if (e.key === CAPABILITY_KEY) onChange();+ };+ window.addEventListener("storage", onStorage);+ return () => {+ subscribers.delete(onChange);+ window.removeEventListener("storage", onStorage);+ };+}diff --git a/src/services/SyncService.ts b/src/services/SyncService.tsindex 29a8ef90d..c862febf1 100644--- a/src/services/SyncService.ts+++ b/src/services/SyncService.ts@@ -13,6 +13,7 @@ import { TranscriptionsService } from "./TranscriptionsService.js";import { DictionaryService } from "./DictionaryService.js";import { SnippetService, type CloudSnippetEntry } from "./SnippetService.js";import { CloudApiError } from "./cloudApi.js";+import { notifyTeamSpacesCapabilityChanged } from "../lib/teamSpacesCapability";function isHttpStatus(err: unknown, status: number): boolean {return err instanceof CloudApiError && err.status === status;@@ -151,8 +152,10 @@ class SyncService {}private cacheTeamSpacesCapability(available: boolean): void {+ const changed = localStorage.getItem("teamSpacesCapability") !== String(available);localStorage.setItem("teamSpacesCapability", String(available));localStorage.setItem("teamSpacesCapability.probedAt", new Date().toISOString());+ if (changed) notifyTeamSpacesCapabilityChanged();}// Sign-out leaves no team content behind: purge every team space locally and@@ -176,11 +179,18 @@ class SyncService {}localStorage.removeItem("teamSpacesCapability");localStorage.removeItem("teamSpacesCapability.probedAt");+ notifyTeamSpacesCapabilityChanged();localStorage.removeItem("lastSyncedAt.notes.team");localStorage.removeItem("lastSyncedAt.folders.team");// The guard protected any pass still in flight during the purge; drop it// so the next account (possibly a member of the same teams) starts clean.localStorage.removeItem(PURGED_TEAM_GUARD_KEY);+ // Both keep local numeric/account-scoped ids that collide across+ // accounts: the workspace selection and the tree's expanded containers.+ // The purge loop above has completed, so nothing re-reads them before the+ // sign-out reload; the next account starts from defaults.+ localStorage.removeItem("activeWorkspaceId");+ localStorage.removeItem("notesTree.expanded");}// lastSyncedAt is written only when a syncAll() pass completes, and