Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

982 B
Raw Blame
import { defineReplica } from '@/libs/replica';
import type { ImageGenerationTopic } from '@/types/generation';

/**
 * The music generation topics list is a single entry per cache scope. The
 * server returns every topic the caller may see (`getAllGenerationTopics('music')`),
 * so there is no server-side filter or pagination to keep apart — the only
 * partition is the identity scope (`${userId}:${workspaceId}`), which the
 * replica owns.
 */
export const GENERATION_TOPICS_KEY = 'music';

/**
 * Music generation topics of the active scope. Read through
 * `generationTopicSelectors.generationTopics`; the persisted copy keeps the
 * sidebar and the routed topic panel populated instead of flashing a skeleton
 * on the first frame after a reload.
 */
export const generationTopicsResource = defineReplica<
  Record<string, never>,
  ImageGenerationTopic[]
>({
  key: () => GENERATION_TOPICS_KEY,
  name: 'musicGenerationTopics',
  storage: 'indexedDB',
  version: 1,
});