import { create } from "zustand"; import { useWebRTCStore } from "./webrtc-store"; interface VoiceState { activeChannel: { serverId: string; channelId: string } | null; error: string | null; // Actions joinVoiceChannel: (serverId: string, channelId: string) => void; leaveVoiceChannel: () => void; setError: (error: string) => void; resetError: () => void; } export const useVoiceStateStore = create()((set, get) => { return { activeChannel: null, error: null, joinVoiceChannel: (serverId, channelId) => { set({ activeChannel: { serverId, channelId }, error: null, }); }, leaveVoiceChannel: () => { const currentState = get(); if (currentState.activeChannel) { useWebRTCStore.getState().disconnect(); set({ activeChannel: null, }); } }, setError: (error) => { set({ error }); }, resetError: () => { set({ error: null }); }, }; });