64 lines
3.0 KiB
TypeScript
64 lines
3.0 KiB
TypeScript
// Metro module 16136 (f16137).
|
|
import StageChannelRoleStore from "../stage_channels/StageChannelRoleStore";
|
|
import VoiceStateRecord from "../../records/VoiceStateRecord";
|
|
import AuthenticationStore from "../../stores/AuthenticationStore";
|
|
import ChannelStore from "../../stores/ChannelStore";
|
|
import MediaEngineStore from "../../stores/MediaEngineStore";
|
|
import RTCConnectionStore from "../../stores/RTCConnectionStore";
|
|
import { InputModes } from "../../Constants";
|
|
import { NativePermissionTypes } from "../native_permissions/NativePermissionConstants";
|
|
import NativePermissionUtils from "../native_permissions/NativePermissionUtils";
|
|
import setAudioInputEnabled_android from "./utils/setAudioInputEnabled.android";
|
|
import { getAudienceRequestToSpeakState, RequestToSpeakStates } from "../stage_channels/useAudienceRequestToSpeakState";
|
|
import AutomaticLifecycleManager from "../../lib/AutomaticLifecycleManager";
|
|
let $mk98768 = function() {
|
|
return (a0) => {
|
|
if (a0) {
|
|
setAudioInputEnabled_android(true);
|
|
}
|
|
};
|
|
};
|
|
const channelId = null;
|
|
class VoicePermissionManager extends AutomaticLifecycleManager {
|
|
actions = {
|
|
VOICE_STATE_UPDATES: this.handleVoiceStateUpdates,
|
|
VOICE_CHANNEL_SELECT: this.handleVoiceChannelSelect
|
|
};
|
|
handleVoiceChannelSelect(a0) {
|
|
if (a0.channelId == null) {
|
|
channelId = null;
|
|
}
|
|
}
|
|
handleVoiceStateUpdates(a0) {
|
|
a0.voiceStates.forEach((voiceState) => {
|
|
const { userId, channelId: channelId2 } = voiceState;
|
|
if (channelId2 != null && AuthenticationStore.getId() === userId && RTCConnectionStore.getRTCConnectionId() != null && channelId !== channelId2) {
|
|
const channel = ChannelStore.getChannel(channelId2);
|
|
const r21 = channel == null ? void 0 : channel.isListenModeCapable();
|
|
if (r21 ? StageChannelRoleStore.isSpeaker(userId, channelId2) : !r21) {
|
|
channelId = channelId2;
|
|
NativePermissionUtils.requestPermission(NativePermissionTypes.AUDIO).then($mk98768());
|
|
if (MediaEngineStore.getMode() === InputModes.PUSH_TO_TALK) {
|
|
NativePermissionUtils.requestPermission(NativePermissionTypes.INPUT_MONITORING);
|
|
}
|
|
return void 0;
|
|
}
|
|
if (getAudienceRequestToSpeakState(new VoiceStateRecord(voiceState)) === RequestToSpeakStates.REQUESTED_TO_SPEAK_AND_AWAITING_USER_ACK) {
|
|
channelId = channelId2;
|
|
NativePermissionUtils.requestPermission(NativePermissionTypes.AUDIO).then($mk98768());
|
|
if (MediaEngineStore.getMode() === InputModes.PUSH_TO_TALK) {
|
|
NativePermissionUtils.requestPermission(NativePermissionTypes.INPUT_MONITORING);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
const voicePermissionManager = new VoicePermissionManager();
|
|
export default voicePermissionManager;
|
|
export function shouldImmediatelyRequestVoicePermissions(a0, a1) {
|
|
const channel = ChannelStore.getChannel(a1);
|
|
const r7 = channel == null ? void 0 : channel.isListenModeCapable();
|
|
return r7 ? StageChannelRoleStore.isSpeaker(a0, a1) : !r7;
|
|
}
|