239 lines
14 KiB
TypeScript
239 lines
14 KiB
TypeScript
// Metro module 16029 (f16030).
|
|
import { useCallback, useContext } from "react";
|
|
import EmbeddedActivitiesStore from "../../../activities/EmbeddedActivitiesStore";
|
|
import ChannelRTCStore from "../../../calls/ChannelRTCStore";
|
|
import UnsyncedUserSettingsStore from "../../../user_settings/UnsyncedUserSettingsStore";
|
|
import ChannelCallLifecycleStore from "../../../video_calls/native/ChannelCallLifecycleStore";
|
|
import ApplicationStreamingStore from "../../../../stores/ApplicationStreamingStore";
|
|
import AuthenticationStore from "../../../../stores/AuthenticationStore";
|
|
import MediaEngineStore from "../../../../stores/MediaEngineStore";
|
|
import VoiceStateStore from "../../../../stores/VoiceStateStore";
|
|
import { AnalyticEvents, PlatformTypes } from "../../../../Constants";
|
|
import { SelfStreamAndVideoAlertType } from "../../../calls/HideSelfStreamAndVideoConstants";
|
|
import { MediaEngineContextTypes } from "../../../../_bundle/Module4250";
|
|
import AlertActionCreators from "../../../../actions/native/AlertActionCreators";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import useGameConsoleAccounts from "../../../game_console/useGameConsoleAccounts";
|
|
import { TableRowGroup } from "../../../../design/components/TableRow/native/TableRowGroup.native";
|
|
import useIsVoiceChannelFull, { useIsVoiceChannelLocked } from "../../../voice_calls/useIsVoiceChannelFull";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import ToastActionCreators from "../../../toast/native/ToastActionCreators";
|
|
import { useOnConnectToConsole } from "../../../video_calls/native/useOnConnectToConsole";
|
|
import getConsoleIcon from "../../../game_console/native/getConsoleIcon";
|
|
import { TableRow } from "../../../../design/components/TableRow/native/TableRow.native";
|
|
import { TableRowIcon } from "../../../../design/components/TableRow/native/TableRowIcon.native";
|
|
import VoicePanelStateContext from "../VoicePanelStateContext";
|
|
import { VoicePanelTabAnalyticsSources } from "./trackVoicePanelTabOpened";
|
|
import { AppsIcon } from "../../../../design/components/Icon/native/redesign/generated/AppsIcon";
|
|
import { ChatIcon } from "../../../../design/components/Icon/native/redesign/generated/ChatIcon";
|
|
import useSoundboardConfig, { SoundboardButtonLocation } from "../hooks/useSoundboardConfig";
|
|
import { SoundboardIcon } from "../../../../design/components/Icon/native/redesign/generated/SoundboardIcon";
|
|
import useScreenshareUtils from "../../../video_calls/native/useScreenshareUtils";
|
|
import AnalyticsUtils from "../../../../utils/AnalyticsUtils";
|
|
import useMuteAwareLocalVolume from "../../../media_engine/useMuteAwareLocalVolume";
|
|
import VolumeSlider from "../../../../components_native/common/VolumeSlider";
|
|
import { isAndroid } from "../../../../utils/PlatformUtils";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import AudioActionCreators from "../../../../actions/AudioActionCreators";
|
|
import { TableSwitchRow } from "../../../../design/components/TableRow/native/TableSwitchRow.native";
|
|
import { HeadphonesSlashIcon } from "../../../../design/components/Icon/native/redesign/generated/HeadphonesSlashIcon";
|
|
import Module15943 from "../../../../_bundle/Module15943";
|
|
import { useMaskedSpeakerStates } from "../../../voice_calls/native/CallsUtils";
|
|
import { showAudioOutputSelector } from "../../../voice_calls/native/audio_output_selector/showAudioOutputSelector";
|
|
import { TableRowArrow } from "../../../../design/components/TableRow/native/TableRowArrow.native";
|
|
import { useCanInviteMembers } from "../hooks/useCanInviteMembers";
|
|
import { useInviteMembersCallback } from "../hooks/useInviteMembersCallback";
|
|
import { GroupPlusIcon } from "../../../../design/components/Icon/native/redesign/generated/GroupPlusIcon";
|
|
import Module10795 from "../../../../_bundle/Module10795";
|
|
import ChannelRTCActionCreators from "../../../../actions/ChannelRTCActionCreators";
|
|
import { VideoIcon } from "../../../../design/components/Icon/native/redesign/generated/VideoIcon";
|
|
import Module10744 from "../../../../_bundle/Module10744";
|
|
import useHideSelfVideo from "../../../calls/useHideSelfVideo";
|
|
import { UserSquareIcon } from "../../../../design/components/Icon/native/redesign/generated/UserSquareIcon";
|
|
import Module10440 from "../../../../_bundle/Module10440";
|
|
import EmbeddedActivitiesNativeManager from "../../../activities/native/EmbeddedActivitiesNativeManager";
|
|
import { shareActivityLogs, reportStreamIssue, rtcDebugPanel } from "../../../video_calls/native/ChannelCallUtils";
|
|
import Module7690 from "../../../../_bundle/Module7690";
|
|
import Dispatcher from "../../../../Dispatcher";
|
|
import { showVoiceSettingsActionSheet } from "../../../video_calls/native/components/ChannelCallConnectingScreen";
|
|
import { SettingsIcon } from "../../../../design/components/Icon/native/redesign/generated/SettingsIcon";
|
|
import Module15942 from "../../../../_bundle/Module15942";
|
|
let toggleDeaf;
|
|
const GameConsoleAccountButton = function GameConsoleAccountButton(props) {
|
|
let onConnectToConsole;
|
|
const { channel, account, connected: connected3 } = props;
|
|
onConnectToConsole = void 0;
|
|
const isVoiceChannelFull = useIsVoiceChannelFull(channel);
|
|
const r21 = useIsVoiceChannelLocked(channel) && !channel.isPrivate();
|
|
let c22730_1 = r21;
|
|
const stateFromStores3 = useStateFromStores([VoiceStateStore], () => VoiceStateStore.isInChannel(channel.id));
|
|
const disabled = (stateFromStores3 ? !stateFromStores3 : isVoiceChannelFull) || r21;
|
|
const callback = useCallback(() => {
|
|
ToastActionCreators.open({
|
|
key: c22730_1 ? intl.string(t.rimHDW) : intl.string(t.rZfiNq),
|
|
content: c22730_1 ? intl.string(t.rimHDW) : intl.string(t.rZfiNq)
|
|
});
|
|
}, [r21]);
|
|
onConnectToConsole = useOnConnectToConsole(channel, account);
|
|
let onPress3 = useCallback(() => {
|
|
onConnectToConsole();
|
|
}, [onConnectToConsole]);
|
|
const type = account.type;
|
|
const label = type === PlatformTypes.XBOX ? connected3 ? intl.string(t["qVE/VF"]) : intl.string(t.E8euSk) : type === PlatformTypes.PLAYSTATION ? connected3 ? intl.string(t.vzfxmY) : intl.string(t.QxEYDj) : type === PlatformTypes.PLAYSTATION_STAGING ? connected3 ? intl.string(t.BDiXtV) : intl.string(t["bhdB9+"]) : void 0;
|
|
const consoleIcon = getConsoleIcon(account.type);
|
|
const r2 = label == null;
|
|
let r82 = null;
|
|
if (!r2) {
|
|
const icon = consoleIcon != null ? <TableRowIcon source={consoleIcon} /> : void 0;
|
|
if (disabled) {
|
|
onPress3 = callback;
|
|
}
|
|
r82 = <TableRow icon={icon} label={label} disabled={disabled} onPress={onPress3} />;
|
|
}
|
|
return r82;
|
|
};
|
|
toggleDeaf = function toggleDeaf() {
|
|
AudioActionCreators.toggleSelfDeaf();
|
|
};
|
|
export function GameConsoles(props) {
|
|
const { channel: channel2, connected } = props;
|
|
const gameConsoleAccounts = useGameConsoleAccounts();
|
|
return gameConsoleAccounts.length > 0 ? <TableRowGroup title={intl.string(t["mbi/fB"])} hasIcons>
|
|
{gameConsoleAccounts.map((gameConsoleAccount) => <GameConsoleAccountButton key={gameConsoleAccount.type} account={gameConsoleAccount} channel={channel2} connected={connected} />)}
|
|
</TableRowGroup> : null;
|
|
}
|
|
export { GameConsoleAccountButton };
|
|
export function ActivitiesButton(props) {
|
|
const openTab = props.openTab;
|
|
const dismissPanel = useContext(VoicePanelStateContext).dismissPanel;
|
|
return <TableRow onPress={useCallback(() => {
|
|
dismissPanel();
|
|
setTimeout(() => {
|
|
openTab({
|
|
tab: "app_launcher",
|
|
source: VoicePanelTabAnalyticsSources.VOICE_CONTROLS
|
|
});
|
|
}, 200);
|
|
}, [dismissPanel, openTab])} icon={<TableRowIcon IconComponent={AppsIcon} />} label={intl.string(t.aeuOoh)} />;
|
|
}
|
|
export function ChatButton(props) {
|
|
const openTab2 = props.openTab;
|
|
const dismissPanel2 = useContext(VoicePanelStateContext).dismissPanel;
|
|
return <TableRow onPress={useCallback(() => {
|
|
dismissPanel2();
|
|
setTimeout(() => {
|
|
openTab2({
|
|
tab: "chat",
|
|
source: VoicePanelTabAnalyticsSources.VOICE_CONTROLS
|
|
});
|
|
}, 200);
|
|
}, [dismissPanel2, openTab2])} icon={<TableRowIcon IconComponent={ChatIcon} />} label={intl.string(t["5KxXrK"])} />;
|
|
}
|
|
export function SoundboardButton(props) {
|
|
const soundboardConfig = useSoundboardConfig(props.channel.id, SoundboardButtonLocation.VOICE_CONTROLS);
|
|
const { visible, handlePress, disabled } = soundboardConfig;
|
|
return visible ? <TableRow label={intl.string(t.ABjMWI)} onPress={handlePress} disabled={disabled} icon={<TableRowIcon IconComponent={SoundboardIcon} />} /> : null;
|
|
}
|
|
export function ScreenshareButton(props) {
|
|
const channel4 = props.channel;
|
|
const screenshareUtils = useScreenshareUtils(channel4);
|
|
const { onPress: onPress2, imgSource, text, isFeatureEnabled, isActive } = screenshareUtils;
|
|
return <TableRow disabled={!isFeatureEnabled} onPress={useCallback(() => {
|
|
AnalyticsUtils.track(AnalyticEvents.VOICE_PANEL_SCREENSHARE_BUTTON_TAPPED, {
|
|
source: "voice controls",
|
|
was_active: isActive
|
|
});
|
|
onPress2();
|
|
}, [isActive, onPress2])} icon={<TableRowIcon source={imgSource} />} label={text} />;
|
|
}
|
|
export function StreamVolumeItem() {
|
|
const stateFromStores3 = useStateFromStores([ApplicationStreamingStore, AuthenticationStore], () => {
|
|
const lastActiveStream = ApplicationStreamingStore.getLastActiveStream();
|
|
return lastActiveStream != null ? lastActiveStream.ownerId !== AuthenticationStore.getId() ? lastActiveStream : null : null;
|
|
});
|
|
const muteAwareLocalVolume = useMuteAwareLocalVolume(stateFromStores3?.ownerId, MediaEngineContextTypes.STREAM);
|
|
const { effectiveVolume, handleVolumeChange } = muteAwareLocalVolume;
|
|
return stateFromStores3 == null ? null : <TableRowGroup title={intl.string(t.pEAl4b)} hasIcons={false}>
|
|
<TableRow label={<VolumeSlider onResponderGrant={isAndroid() ? () => true : void 0} value={effectiveVolume} onValueChange={handleVolumeChange} color={Module712.unsafe_rawColors.WHITE} maxTrackTintColor={Module712.unsafe_rawColors.PRIMARY_300} />} />
|
|
</TableRowGroup>;
|
|
}
|
|
export function DeafenSwitch() {
|
|
const stateFromStores3 = useStateFromStores([MediaEngineStore], () => MediaEngineStore.isSelfDeaf());
|
|
return <TableSwitchRow icon={<TableRowIcon IconComponent={HeadphonesSlashIcon} source={Module15943} />} accessibilityHint={intl.string(t.wjcRFX)} value={stateFromStores3} onValueChange={toggleDeaf} label={intl.string(t.wjcRFX)} subLabel={intl.string(t.M3VN2U)} />;
|
|
}
|
|
export function AudioRouteButton(props) {
|
|
const { channel: channel3, connected: connected2 } = props;
|
|
return <TableRow icon={<TableRowIcon source={useMaskedSpeakerStates().routeSource} />} onPress={() => {
|
|
showAudioOutputSelector(channel3.id, connected2);
|
|
}} label={intl.string(t["A/Ly/2"])} trailing={<TableRowArrow />} />;
|
|
}
|
|
export function InviteButton(props) {
|
|
const { channel: channel4, connected: connected3 } = props;
|
|
const canInviteMembers = useCanInviteMembers(channel4.id);
|
|
const isVoiceChannelFull = useIsVoiceChannelFull(channel4);
|
|
const inviteMembersCallback = useInviteMembersCallback(channel4.id);
|
|
return isVoiceChannelFull ? null : canInviteMembers ? connected3 ? <TableRow onPress={inviteMembersCallback} icon={<TableRowIcon IconComponent={GroupPlusIcon} source={Module10795} />} label={intl.string(t["f1+QIK"])} trailing={<TableRowArrow />} /> : null : null;
|
|
}
|
|
export function HideNonVideoParticipants(props) {
|
|
const channelId = props.channelId;
|
|
const stateFromStores = useStateFromStores([ChannelRTCStore], () => ChannelRTCStore.getVoiceParticipantsHidden(channelId));
|
|
const callback = useCallback(() => {
|
|
ChannelRTCActionCreators.toggleVoiceParticipantsHidden(channelId, !stateFromStores);
|
|
}, [channelId, stateFromStores]);
|
|
return <TableSwitchRow icon={<TableRowIcon IconComponent={VideoIcon} source={Module10744} />} accessibilityHint={intl.string(t.ZMTRyc)} value={stateFromStores} onValueChange={callback} label={intl.string(t.ZMTRyc)} subLabel={intl.string(t.MlpCFS)} />;
|
|
}
|
|
export function HideSelfVideo() {
|
|
let [r20, r9, c22737_1] = useHideSelfVideo(AuthenticationStore.getId());
|
|
let c22737_0 = r9;
|
|
const stateFromStores2 = useStateFromStores([UnsyncedUserSettingsStore], () => UnsyncedUserSettingsStore.disableHideSelfStreamAndVideoConfirmationAlert);
|
|
return r20 ? <TableSwitchRow icon={<TableRowIcon IconComponent={UserSquareIcon} />} value={!r9} onValueChange={function onValueChange() {
|
|
if (!stateFromStores2 && !c22737_0) {
|
|
const VIDEO = SelfStreamAndVideoAlertType.VIDEO;
|
|
const onConfirm = () => c22737_1(!c22737_0);
|
|
AlertActionCreators.openLazy({
|
|
importer: () => import("../../../video_calls/native/components/HideSelfStreamAndVideoConfirmDialog").then(({ default: Component }) => (a0) => <Component {...a0} type={VIDEO} onConfirm={onConfirm} />)
|
|
});
|
|
return void 0;
|
|
}
|
|
return c22737_1(!c22737_0);
|
|
}} label={intl.string(t.MH8ESU)} /> : null;
|
|
}
|
|
export function LeaveActivitiesButton() {
|
|
return <TableRow icon={<TableRowIcon source={Module10440} />} label={intl.string(t["R/FK4A"])} onPress={function onPress() {
|
|
const currentEmbeddedActivity = EmbeddedActivitiesStore.getCurrentEmbeddedActivity();
|
|
EmbeddedActivitiesNativeManager.leaveActivity({
|
|
location: currentEmbeddedActivity?.location,
|
|
applicationId: currentEmbeddedActivity?.applicationId
|
|
});
|
|
}} />;
|
|
}
|
|
export function ShareActivityLogsButton() {
|
|
const r11 = shareActivityLogs();
|
|
const { label, icon } = r11;
|
|
return <TableRow icon={icon != null ? <TableRowIcon source={icon} /> : void 0} label={label} onPress={r11.onPress} />;
|
|
}
|
|
export function ToggleShowActivitiesDebugOverlay() {
|
|
return <TableSwitchRow icon={<TableRowIcon source={Module7690} />} value={useStateFromStores([ChannelCallLifecycleStore], () => ChannelCallLifecycleStore.getShowActivitiesDebugOverlay())} onValueChange={function onValueChange(value) {
|
|
Dispatcher.dispatch({
|
|
type: "EMBEDDED_ACTIVITY_SET_DEBUG_OVERLAY_VISIBILITY",
|
|
visible: value
|
|
});
|
|
}} label={intl.string(t["qv5/SP"])} />;
|
|
}
|
|
export function VoiceSettingsButton(props) {
|
|
const guildId = props.guildId;
|
|
return <TableRow onPress={useCallback(() => {
|
|
showVoiceSettingsActionSheet(guildId);
|
|
}, [guildId])} icon={<TableRowIcon IconComponent={SettingsIcon} source={Module15942} />} label={intl.string(t.NiTd0e)} subLabel={intl.string(t["16SG+O"])} trailing={<TableRowArrow />} />;
|
|
}
|
|
export function ReportStreamIssueButton(props) {
|
|
const r12 = reportStreamIssue(props.stream);
|
|
const { label, icon } = r12;
|
|
return <TableRow icon={icon != null ? <TableRowIcon source={icon} /> : void 0} label={label} onPress={r12.onPress} />;
|
|
}
|
|
export function RTCDebugPanelButton() {
|
|
const r11 = rtcDebugPanel(() => {});
|
|
const { label, onPress: onPress3, icon } = r11;
|
|
return <TableRow icon={icon != null ? <TableRowIcon source={icon} /> : void 0} label={label} onPress={onPress3} />;
|
|
}
|