"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; sync: (records: TrackActivity[]) => void; clear: () => void; }>((set) => ({ activity: {}, sync: (records) => set({ activity: Object.fromEntries(records.map((r) => [r.id, r])) }), clear: () => set({ activity: {} }), }));