Something went wrong. Try again.
Effortlessly glide through your todos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142import { useSyncExternalStore } from 'react';
/** * The account the local data belongs to. * * The active account for newly-created local rows. * * `null` means signed-out local mode. Existing dogfood rows are treated as adoptable * legacy rows so the first Clerk sign-in can claim them into the authenticated account. */export const DOGFOOD_OWNER = 'dogfood';
let activeOwnerId: string | null = null;const listeners = new Set<() => void>();
export function currentOwnerId(): string | null { return activeOwnerId;}
export function setCurrentOwnerId(ownerId: string | null): void { if (activeOwnerId === ownerId) return; activeOwnerId = ownerId; listeners.forEach((listener) => listener());}
function subscribe(listener: () => void): () => void { listeners.add(listener); return () => listeners.delete(listener);}
export function useCurrentOwnerId(): string | null { return useSyncExternalStore(subscribe, currentOwnerId, currentOwnerId);}
export function isAdoptableOwner(ownerId: string | null): boolean { return ownerId === null || ownerId === DOGFOOD_OWNER;}
export function isVisibleForOwner(taskOwnerId: string | null, ownerId: string | null): boolean { return isAdoptableOwner(taskOwnerId) || (ownerId !== null && taskOwnerId === ownerId);}