Spaces:
Sleeping
Sleeping
Download frontend/src/lib/store/libraryStore.ts from kishankrish19/Chat: direct link, hf CLI and curl.
- Browser
- Download file 558 Bytes
-
https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/frontend/src/lib/store/libraryStore.ts
- Command line
-
hf download hf://spaces/kishankrish19/Chat/frontend/src/lib/store/libraryStore.ts
-
curl -L -o libraryStore.ts https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/frontend/src/lib/store/libraryStore.ts
558 Bytes
| "use client"; | |
| import { create } from "zustand"; | |
| import type { TrackActivity } from "../api/apiClient"; | |
| // One authenticated poll keeps every visible song up to date. Never persist | |
| // another listener's private library state in the browser. | |
| export const useLibraryStore = create<{ | |
| activity: Record<string, TrackActivity>; | |
| sync: (records: TrackActivity[]) => void; | |
| clear: () => void; | |
| }>((set) => ({ | |
| activity: {}, | |
| sync: (records) => | |
| set({ activity: Object.fromEntries(records.map((r) => [r.id, r])) }), | |
| clear: () => set({ activity: {} }), | |
| })); | |