Files
discord-decomp/modules/voice_panel/native/hooks/useIsConnectedToVoiceChannel.tsx
T
2026-11-01 12:12:55 +02:00

27 lines
1012 B
TypeScript

// Metro module 15863 (f15864).
import AuthenticationStore from "../../../../stores/AuthenticationStore";
import RTCConnectionStore from "../../../../stores/RTCConnectionStore";
import VoiceStateStore from "../../../../stores/VoiceStateStore";
import { RTCConnectionStates } from "../../../../Constants";
import { useStateFromStores } from "../../../../_bundle/Module589";
export default function useIsConnectedToVoiceChannel(c22529_0) {
return useStateFromStores([RTCConnectionStore, VoiceStateStore, AuthenticationStore], () => {
const channelId = RTCConnectionStore.getChannelId();
let r6 = c22529_0;
if (r6 == null) {
r6 = channelId;
}
if (r6 !== channelId) {
return false;
}
if (VoiceStateStore.isInChannel(r6, AuthenticationStore.getId())) {
return true;
}
const state = RTCConnectionStore.getState();
if (RTCConnectionStates.DISCONNECTED !== state && RTCConnectionStates.NO_ROUTE !== state) {
return true;
}
return false;
});
};