Files
voicebox/app/src/stores/audioChannelStore.ts
T
Jamie Pine 30ea627ae8 Implement audio channel management features
- Added new components for managing audio channels, including creation, updating, and deletion of channels.
- Introduced a new AudioTab for channel management and integrated it into the main application layout.
- Updated the API client to support audio channel operations and added corresponding backend endpoints.
- Enhanced the player store to handle audio playback routing through assigned channels.
- Refactored existing components to accommodate the new audio channel functionality, including updates to the HistoryTable and GenerationForm for profile-channel associations.
- Improved sidebar navigation to include new tabs for Voices and Audio management.
2026-01-26 19:20:20 -08:00

45 lines
1.1 KiB
TypeScript

import { create } from 'zustand';
import { persist } from 'zustand/middleware';
export interface AudioChannel {
id: string;
name: string;
is_default: boolean;
device_ids: string[];
created_at: string;
}
interface AudioChannelStore {
channels: AudioChannel[];
setChannels: (channels: AudioChannel[]) => void;
addChannel: (channel: AudioChannel) => void;
updateChannel: (id: string, channel: Partial<AudioChannel>) => void;
removeChannel: (id: string) => void;
}
export const useAudioChannelStore = create<AudioChannelStore>()(
persist(
(set) => ({
channels: [],
setChannels: (channels) => set({ channels }),
addChannel: (channel) =>
set((state) => ({
channels: [...state.channels, channel],
})),
updateChannel: (id, updates) =>
set((state) => ({
channels: state.channels.map((ch) =>
ch.id === id ? { ...ch, ...updates } : ch,
),
})),
removeChannel: (id) =>
set((state) => ({
channels: state.channels.filter((ch) => ch.id !== id),
})),
}),
{
name: 'voicebox-audio-channels',
},
),
);