202 lines
8.5 KiB
TypeScript
202 lines
8.5 KiB
TypeScript
// Metro module 15944 (f15945).
|
|
import * as Module19 from "react";
|
|
import { useMemo, useCallback, useRef } from "react";
|
|
import { NativeModules } from "react-native";
|
|
import { setVoiceUpsellDismissed } from "../../../game_console/ConsoleVoiceUpsellStore";
|
|
import GameConsoleStore from "../../../game_console/GameConsoleStore";
|
|
import StageChannelAudioStore from "../../../stage_channels/native/StageChannelAudioStore";
|
|
import AudioRouteStore_native from "../../../voice_calls/AudioRouteStore.native";
|
|
import ChannelStore from "../../../../stores/ChannelStore";
|
|
import SessionsStore from "../../../../stores/SessionsStore";
|
|
import { PlatformTypes } from "../../../../Constants";
|
|
import useSpeakerTooltips from "../hooks/useSpeakerTooltips";
|
|
import useControlsLock from "../controls/useControlsLock";
|
|
import { useMaskedSpeakerStates } from "../../../voice_calls/native/CallsUtils";
|
|
import useIsVideoMode from "../../../video_calls/native/useIsVideoMode";
|
|
import useVoiceStateForRemoteSession from "../../../game_console/hooks/useVoiceStateForRemoteSession";
|
|
import { useStateFromStores } from "../../../../_bundle/defaultAreStatesEqual";
|
|
import getConsoleIcon from "../../../game_console/native/getConsoleIcon";
|
|
import useGameConsoleAccounts from "../../../game_console/useGameConsoleAccounts";
|
|
import useCanConnect from "../hooks/useCanConnect";
|
|
import { isAndroid } from "../../../../utils/PlatformUtils";
|
|
import { showAudioOutputSelector } from "../../../voice_calls/native/audio_output_selector/showAudioOutputSelector";
|
|
import { RouteTypes } from "../../../voice_calls/VoiceCallTypes";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import Module8853 from "../../../../_bundle/Module8853";
|
|
import Module8855 from "../../../../_bundle/Module8855";
|
|
import Module15953 from "../../../../_bundle/Module15953";
|
|
import { onConnectToConsole } from "../../../video_calls/native/useOnConnectToConsole";
|
|
import { UNSAFE_markDismissibleContentAsDismissed } from "../../../dismissible_content/DismissibleContentUnsafeUtils";
|
|
import { DismissibleContent } from "../../../../_bundle/Module1358";
|
|
import NativeView from "../../../core/native/NativeView";
|
|
import VoicePanelIconButton from "../shared/VoicePanelIconButton";
|
|
import { MenuPopout } from "../../../../design/components/Menu/native/MenuPopout";
|
|
const _excluded = ["ref"];
|
|
let c11423_17 = [];
|
|
let Component = Module19.memo(function(a0) {
|
|
useSpeakerTooltips(a0.targetRef, a0.canShowTooltip);
|
|
return null;
|
|
});
|
|
const r48 = Module19.memo(function VoicePanelHeaderSpeaker(props) {
|
|
let stateFromStores2, stateFromStores3, memo, c22631_13, c22631_14, callback, stateFromStores4, ref;
|
|
const { isConnectedToVoiceChannel, channelId, style } = props;
|
|
stateFromStores2 = void 0;
|
|
stateFromStores3 = void 0;
|
|
memo = void 0;
|
|
c22631_13 = void 0;
|
|
c22631_14 = void 0;
|
|
callback = void 0;
|
|
stateFromStores4 = void 0;
|
|
ref = void 0;
|
|
const controlsLock = useControlsLock();
|
|
let c22631_3 = controlsLock;
|
|
const maskedSpeakerStates = useMaskedSpeakerStates();
|
|
const { toggleAudio, routeSource, isAudioRouteEnabled } = maskedSpeakerStates;
|
|
const isVideoMode = useIsVideoMode();
|
|
let c22631_7 = isVideoMode;
|
|
let c22631_8 = useVoiceStateForRemoteSession();
|
|
const stateFromStores = useStateFromStores([GameConsoleStore], () => GameConsoleStore.getAwaitingRemoteSessionInfo());
|
|
stateFromStores2 = useStateFromStores([StageChannelAudioStore], () => StageChannelAudioStore.getQueueAudioSwap());
|
|
stateFromStores3 = useStateFromStores([SessionsStore], () => {
|
|
let r7 = c22631_8?.sessionId;
|
|
if (r7 == null) {
|
|
r7 = "";
|
|
}
|
|
return SessionsStore.getSessionById(r7);
|
|
});
|
|
memo = useMemo(() => {
|
|
let r4 = stateFromStores?.type;
|
|
if (r4 == null) {
|
|
r4 = stateFromStores3 == null ? void 0 : stateFromStores3.clientInfo?.os;
|
|
}
|
|
return r4 != null ? getConsoleIcon(r4) : null;
|
|
}, [stateFromStores, stateFromStores3]);
|
|
const gameConsoleAccounts = useGameConsoleAccounts();
|
|
c22631_13 = gameConsoleAccounts;
|
|
const r3 = gameConsoleAccounts.length > 0;
|
|
const canConnect = useCanConnect(channelId);
|
|
let canConnect2 = canConnect.canConnect;
|
|
const isAtMaxCapacity = canConnect.isAtMaxCapacity;
|
|
if (canConnect2) {
|
|
canConnect2 = !isAtMaxCapacity;
|
|
}
|
|
if (canConnect2) {
|
|
canConnect2 = isConnectedToVoiceChannel ? isConnectedToVoiceChannel : r3;
|
|
}
|
|
c22631_14 = canConnect2;
|
|
callback = useCallback(() => {
|
|
if (isAndroid()) {
|
|
showAudioOutputSelector(channelId, isConnectedToVoiceChannel);
|
|
} else {
|
|
toggleAudio(channelId, isConnectedToVoiceChannel);
|
|
}
|
|
}, [channelId, isConnectedToVoiceChannel, toggleAudio]);
|
|
stateFromStores4 = useStateFromStores([AudioRouteStore_native], () => AudioRouteStore_native.getCurrentRouteType());
|
|
const memo2 = useMemo(() => {
|
|
if (!isAndroid()) {
|
|
if (c22631_13.length !== 0) {
|
|
const r30 = [];
|
|
let c28189_0 = r30;
|
|
let r3 = c22631_7;
|
|
if (!(r3 ? r3 : stateFromStores4 !== RouteTypes.SPEAKER)) {
|
|
r30.push({
|
|
label: intl.string(t.gvQIzx),
|
|
iconSource: Module8853,
|
|
showIconFirst: false,
|
|
action: () => {
|
|
const AudioRoutePicker = NativeModules.AudioRoutePicker;
|
|
return AudioRoutePicker == null ? void 0 : AudioRoutePicker.toggleSpeaker(false);
|
|
}
|
|
});
|
|
}
|
|
if (!r3) {
|
|
r3 = stateFromStores4 !== RouteTypes.RECEIVER;
|
|
}
|
|
if (!r3) {
|
|
r30.push({
|
|
label: intl.string(t.wwTN1g),
|
|
iconSource: Module8855,
|
|
showIconFirst: false,
|
|
action: () => {
|
|
const AudioRoutePicker = NativeModules.AudioRoutePicker;
|
|
return AudioRoutePicker == null ? void 0 : AudioRoutePicker.toggleSpeaker(true);
|
|
}
|
|
});
|
|
}
|
|
r30.push({
|
|
label: intl.string(t.dnI0AL),
|
|
iconSource: Module15953,
|
|
showIconFirst: false,
|
|
action: () => {
|
|
showAudioOutputSelector(channelId, isConnectedToVoiceChannel);
|
|
}
|
|
});
|
|
const _loop = function _loop(a0) {
|
|
if (a0.type === PlatformTypes.XBOX) {
|
|
c28189_0.push({
|
|
label: intl.string(t["qVE/VF"]),
|
|
iconSource: getConsoleIcon(a0.type),
|
|
showIconFirst: false,
|
|
action: () => {
|
|
const channel = ChannelStore.getChannel(channelId);
|
|
if (channel != null) {
|
|
onConnectToConsole(channel, a0);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
if (a0.type === PlatformTypes.PLAYSTATION) {
|
|
c28189_0.push({
|
|
label: intl.string(t.vzfxmY),
|
|
iconSource: getConsoleIcon(a0.type),
|
|
showIconFirst: false,
|
|
action: () => {
|
|
const channel = ChannelStore.getChannel(channelId);
|
|
if (channel != null) {
|
|
onConnectToConsole(channel, a0);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
};
|
|
for (const item of c22631_13) {
|
|
_loop(item);
|
|
}
|
|
return r30;
|
|
}
|
|
}
|
|
return c11423_17;
|
|
}, [gameConsoleAccounts, channelId, isConnectedToVoiceChannel, stateFromStores4, isVideoMode]);
|
|
const callback2 = useCallback(() => {
|
|
UNSAFE_markDismissibleContentAsDismissed(DismissibleContent.DONUT_MOBILE_NUX);
|
|
setVoiceUpsellDismissed(true);
|
|
c22631_3.lock();
|
|
}, [controlsLock]);
|
|
ref = useRef(null);
|
|
if (canConnect2) {
|
|
const renderButton = function renderButton(a0) {
|
|
const r6 = a0 == null ? {
|
|
onPress: callback,
|
|
ref: void 0
|
|
} : a0;
|
|
const { ref: ref2, ...rest } = r6;
|
|
const r25 = [<Component targetRef={ref} canShowTooltip={c22631_14 && isConnectedToVoiceChannel} />, ,];
|
|
const overrideVariant = isConnectedToVoiceChannel ? isAudioRouteEnabled ? "primary-overlay" : void 0 : void 0;
|
|
let icon = memo;
|
|
if (memo == null) {
|
|
icon = routeSource;
|
|
}
|
|
r25[1] = <NativeView style={style} ref={ref}>
|
|
<VoicePanelIconButton ref={ref2} {...rest} disabled={stateFromStores2} overrideVariant={overrideVariant} loading={stateFromStores != null} icon={icon} accessibilityLabel={intl.string(t.dnI0AL)} />
|
|
</NativeView>;
|
|
return <>{r25}</>;
|
|
};
|
|
return !isAndroid() && r3 ? <>
|
|
<Component targetRef={ref} canShowTooltip={isConnectedToVoiceChannel} />
|
|
<MenuPopout menuItems={memo2} position="bottom" align="end" onRequestOpen={callback2} onRequestClose={controlsLock.unlock}>{renderButton}</MenuPopout>
|
|
</> : renderButton();
|
|
}
|
|
return null;
|
|
});
|
|
export default r48;
|