decord/alpha/source/stores/PermissionVADStore.tsx

93 lines
3.3 KiB
TypeScript
Raw Permalink Normal View History

2026-10-13 12:43:34 +00:00
// Module ID: 14972
// Function ID: 14973
// Name: PermissionVADStore
2026-10-10 08:08:14 +00:00
// Dependencies: [502, 2065, 2012, 4750, 5110, 5113, 1085, 584, 504, 2]
2026-07-20 16:05:17 +00:00
2026-10-13 12:43:34 +00:00
// Module 14972 (PermissionVADStore)
2026-10-03 08:58:59 +00:00
import get_initializedDefault from "get initialized" /* 504 */;
import DispatcherDefault from "Dispatcher" /* 584 */;
import AuthenticationStore from "AuthenticationStore" /* 502 */;
2026-10-10 08:08:14 +00:00
import ChannelStore from "ChannelStore" /* 2065 */;
2026-10-09 10:00:15 +00:00
import MediaEngineStore from "MediaEngineStore" /* 2012 */;
2026-10-10 08:08:14 +00:00
import PermissionStore from "PermissionStore" /* 4750 */;
import RTCConnectionStore from "RTCConnectionStore" /* 5110 */;
import VoiceStateStore from "VoiceStateStore" /* 5113 */;
2026-10-03 08:58:59 +00:00
import Constants from "Constants" /* 1085 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-03 08:58:59 +00:00
let c9;
let metroImportAll;
2026-07-20 16:05:17 +00:00
function handleUpdateVADPermission() {
const channelId = RTCConnectionStore.getChannelId();
flag = true;
2026-07-20 16:05:17 +00:00
if (null != channelId) {
const channel = ChannelStore.getChannel(channelId);
2026-07-20 16:05:17 +00:00
let guildId;
2026-10-03 08:58:59 +00:00
const getVoiceState = VoiceStateStore.getVoiceState;
2026-07-29 08:29:29 +00:00
if (channel != null) {
2026-07-20 16:05:17 +00:00
guildId = channel.getGuildId();
}
2026-10-03 08:58:59 +00:00
const voiceState = getVoiceState(guildId, AuthenticationStore.getId());
let canResult = MediaEngineStore.getMode() !== metroImportAll.VOICE_ACTIVITY || null == channel || channel.isPrivate() || channel.isGuildStageVoice() || PermissionStore.can(constants2.USE_VAD, channel);
2026-07-20 16:05:17 +00:00
if (!canResult) {
canResult = null == voiceState || voiceState.suppress || null != voiceState.requestToSpeakTimestamp;
}
flag = canResult;
}
2026-07-23 10:11:24 +00:00
let flag2 = flag !== flag;
2026-07-20 16:05:17 +00:00
if (flag2) {
c11 = flag;
const obj = { type: "SET_VAD_PERMISSION", hasPermission: flag };
2026-10-03 08:58:59 +00:00
const obj2 = DispatcherDefault;
obj2.dispatch(obj);
2026-07-20 16:05:17 +00:00
flag2 = true;
}
return flag2;
}
2026-10-03 08:58:59 +00:00
({ InputModes: metroImportAll, Permissions: c9 } = Constants);
let flag = true;
2026-07-29 08:29:29 +00:00
let c11 = true;
2026-10-03 08:58:59 +00:00
const Store = get_initializedDefault.Store;
2026-07-29 08:29:29 +00:00
class PermissionVADStore extends Store {
2026-10-03 08:58:59 +00:00
initialize() {
this.waitFor(AuthenticationStore, ChannelStore, MediaEngineStore, PermissionStore, RTCConnectionStore, VoiceStateStore);
}
shouldShowWarning() {
return !c11;
}
canUseVoiceActivity() {
return flag;
}
2026-07-29 08:29:29 +00:00
}
const prototype = PermissionVADStore.prototype;
PermissionVADStore.displayName = "PermissionVADStore";
2026-10-03 08:58:59 +00:00
let obj = {
2026-07-20 16:05:17 +00:00
RTC_CONNECTION_STATE: handleUpdateVADPermission,
MEDIA_ENGINE_SET_AUDIO_ENABLED: handleUpdateVADPermission,
AUDIO_SET_MODE: handleUpdateVADPermission,
CHANNEL_UPDATES: handleUpdateVADPermission,
THREAD_UPDATE: handleUpdateVADPermission,
GUILD_ROLE_UPDATE: handleUpdateVADPermission,
GUILD_MEMBER_UPDATE: handleUpdateVADPermission,
IMPERSONATE_UPDATE: handleUpdateVADPermission,
IMPERSONATE_STOP: handleUpdateVADPermission,
VOICE_STATE_UPDATES: function handleVoiceStateUpdates(voiceStates) {
2026-10-03 08:58:59 +00:00
let id;
2026-07-20 16:05:17 +00:00
voiceStates = voiceStates.voiceStates;
return voiceStates.some((userId) => {
2026-10-03 08:58:59 +00:00
const tmp = userId.userId === id.getId() && handleUpdateVADPermission();
2026-07-20 16:05:17 +00:00
return tmp;
});
},
AUDIO_TOGGLE_SELF_MUTE: function handleUnclearWarning() {
c11 = flag;
2026-07-20 16:05:17 +00:00
},
PERMISSION_CLEAR_VAD_WARNING: function handleClearWarning() {
2026-08-24 06:08:38 +00:00
c11 = true;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
};
const permissionVADStore = new PermissionVADStore(DispatcherDefault, obj);
const result = size.fileFinishedImporting("stores/PermissionVADStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default permissionVADStore;