144 lines
5.9 KiB
TypeScript
144 lines
5.9 KiB
TypeScript
// Metro module 15932 (f15933).
|
|
import { useContext, useCallback, useMemo } from "react";
|
|
import RTCConnectionStore from "../../../../stores/RTCConnectionStore";
|
|
import VoiceStateStore from "../../../../stores/VoiceStateStore";
|
|
import { ParticipantTypes } from "../../../calls/CallConstants";
|
|
import VoicePanelStateContext from "../VoicePanelStateContext";
|
|
import { useMuteDeafenIconState, useVideoIconState, VideoIconState, MuteDeafenIconState } from "../utils/VoiceStateIconUtils";
|
|
import { useStateFromStores } from "../../../../_bundle/defaultAreStatesEqual";
|
|
import useMuteAwareLocalVolume from "../../../media_engine/useMuteAwareLocalVolume";
|
|
import { MediaEngineContextTypes } from "../../../../_bundle/Module4286";
|
|
import MobileAudioOutputExperiment from "../../../media_engine/MobileAudioOutputExperiment";
|
|
import { useIsRTCDisconnectedUIVisible } from "../../../voice_calls/RTCConnectionDesyncHooks";
|
|
import { OverrideFloatingCTA } from "../controls/utils/VoicePanelFloatingCTAUtils";
|
|
import ToastActionCreators from "../../../toast/native/ToastActionCreators";
|
|
import { CircleErrorIcon } from "../../../../design/components/Icon/native/redesign/generated/CircleErrorIcon";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
let c11414_8 = {
|
|
STREAM_ICON: "STREAM_ICON",
|
|
USER_VIDEO_ICON: "USER_VIDEO_ICON",
|
|
MUTE_DEAFEN_ICON: "MUTE_DEAFEN_ICON",
|
|
USER_DISCONNECTED_ICON: "DISCONNECTED_ICON",
|
|
SPEAKER_MUTE_ICON: "SPEAKER_MUTE_ICON"
|
|
};
|
|
export default function useVoicePanelCardUserStateIcons(a0, a1, a2) {
|
|
let stateFromStores2, c22619_8, isRTCDisconnectedUIVisible, callback, callback2;
|
|
let r12 = arguments[3];
|
|
if (r12 === void 0) {
|
|
r12 = null;
|
|
}
|
|
let c22619_2 = r12;
|
|
stateFromStores2 = void 0;
|
|
c22619_8 = void 0;
|
|
isRTCDisconnectedUIVisible = void 0;
|
|
callback = void 0;
|
|
callback2 = void 0;
|
|
const setShowFloatingCTA = useContext(VoicePanelStateContext).setShowFloatingCTA;
|
|
const muteDeafenIconState = useMuteDeafenIconState(a0 === ParticipantTypes.USER ? a1 : void 0, a2);
|
|
const videoIconState = useVideoIconState(a0 === ParticipantTypes.USER ? a1 : void 0, a2);
|
|
const stateFromStores = useStateFromStores([RTCConnectionStore], () => RTCConnectionStore.isConnected());
|
|
stateFromStores2 = useStateFromStores([VoiceStateStore], () => {
|
|
const r1 = c22619_2 != null;
|
|
let r2 = null;
|
|
if (r1) {
|
|
r2 = a1 != null ? VoiceStateStore.getVoicePlatformForChannel(c22619_2, a1) : null;
|
|
}
|
|
return r2;
|
|
}, [r12, a1]);
|
|
const effectiveVolume = useMuteAwareLocalVolume(a0 === ParticipantTypes.STREAM ? a1 : void 0, MediaEngineContextTypes.STREAM).effectiveVolume;
|
|
const r61 = MobileAudioOutputExperiment.useConfig({
|
|
location: "useVoicePanelCardUserStateIcons"
|
|
}).showTileVolumeIndicator && effectiveVolume === 0 && a0 === ParticipantTypes.STREAM;
|
|
c22619_8 = r61;
|
|
isRTCDisconnectedUIVisible = useIsRTCDisconnectedUIVisible(r12, a1);
|
|
callback = useCallback(() => {
|
|
setShowFloatingCTA(OverrideFloatingCTA.BAD_CONNECTION);
|
|
}, [setShowFloatingCTA]);
|
|
callback2 = useCallback(() => {
|
|
ToastActionCreators.open({
|
|
key: "user-disconnected-indicator",
|
|
icon: () => <CircleErrorIcon size="xs" color={Module712.colors.STATUS_WARNING} />,
|
|
content: intl.string(t.HFwRpk)
|
|
});
|
|
}, []);
|
|
return useMemo(() => {
|
|
if (stateFromStores) {
|
|
if (a0 === ParticipantTypes.STREAM) {
|
|
const r50 = [];
|
|
if (c22619_8) {
|
|
r50.push({
|
|
type: c11414_8.SPEAKER_MUTE_ICON,
|
|
onPress: () => {
|
|
ToastActionCreators.open({
|
|
key: `${a1}-stream-status`,
|
|
content: intl.string(t.Q8Uzof)
|
|
});
|
|
}
|
|
});
|
|
}
|
|
r50.push({
|
|
type: c11414_8.STREAM_ICON,
|
|
voicePlatform: stateFromStores2
|
|
});
|
|
return r50;
|
|
}
|
|
if (a0 !== ParticipantTypes.USER) {
|
|
return [];
|
|
}
|
|
const r15 = [];
|
|
if (isRTCDisconnectedUIVisible) {
|
|
r15.push({
|
|
type: c11414_8.USER_DISCONNECTED_ICON,
|
|
onPress: callback2
|
|
});
|
|
}
|
|
if (videoIconState != null && videoIconState !== VideoIconState.VIDEO_ACTIVE) {
|
|
r15.push({
|
|
type: c11414_8.USER_VIDEO_ICON,
|
|
videoIconState,
|
|
onPress: videoIconState === VideoIconState.VIDEO_DISABLED_LOCAL_AUTO ? callback : void 0
|
|
});
|
|
}
|
|
if (muteDeafenIconState != null) {
|
|
r15.push({
|
|
type: c11414_8.MUTE_DEAFEN_ICON,
|
|
muteDeafenIconState,
|
|
withLeftMargin: r15.length > 0,
|
|
onPress: () => {
|
|
if (MuteDeafenIconState.DEAFENED_SERVER === muteDeafenIconState) {
|
|
ToastActionCreators.open({
|
|
key: `${a1}-status`,
|
|
content: intl.string(t.btxSdB)
|
|
});
|
|
} else if (MuteDeafenIconState.DEAFENED === muteDeafenIconState) {
|
|
ToastActionCreators.open({
|
|
key: `${a1}-status`,
|
|
content: intl.string(t.NjmiOL)
|
|
});
|
|
} else if (MuteDeafenIconState.MUTED_SERVER === muteDeafenIconState) {
|
|
ToastActionCreators.open({
|
|
key: `${a1}-status`,
|
|
content: intl.string(t.uLddbQ)
|
|
});
|
|
} else if (MuteDeafenIconState.MUTED_LOCAL === muteDeafenIconState) {
|
|
ToastActionCreators.open({
|
|
key: `${a1}-status`,
|
|
content: intl.string(t.Q8Uzof)
|
|
});
|
|
} else if (MuteDeafenIconState.MUTED === muteDeafenIconState) {
|
|
ToastActionCreators.open({
|
|
key: `${a1}-status`,
|
|
content: intl.string(t.tjtv3P)
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return r15;
|
|
}
|
|
return [];
|
|
}, [stateFromStores, a0, videoIconState, muteDeafenIconState, isRTCDisconnectedUIVisible, stateFromStores2, callback, a1, callback2, r61]);
|
|
};
|
|
export { c11414_8 as VoicePanelCardUserStateIconType };
|