This commit is contained in:
2025-05-20 04:16:03 +03:00
parent 21a05dd202
commit 9531bff01a
88 changed files with 7797 additions and 2246 deletions

View File

@@ -0,0 +1,46 @@
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<VoiceState>()((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 });
}
};
});