147 lines
6.9 KiB
TypeScript
147 lines
6.9 KiB
TypeScript
// Metro module 10764 (f10765).
|
|
import { useCallback } from "react";
|
|
import * as _Module17 from "react-native";
|
|
import { View } from "react-native";
|
|
import GameConsoleStore from "../../../game_console/GameConsoleStore";
|
|
import MediaEngineStore from "../../../../stores/MediaEngineStore";
|
|
import PermissionStore from "../../../../stores/PermissionStore";
|
|
import SessionsStore from "../../../../stores/SessionsStore";
|
|
import { resetFocus } from "../ChannelCallStore";
|
|
import { InstantInviteSources } from "../../../../Constants";
|
|
import { Permissions } from "../../../../_bundle/Module505";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import { CALL_ACTION_BAR_HEIGHT } from "../useActionBarHeight";
|
|
import ActionSheetActionCreators from "../../../action_sheet/native/ActionSheetActionCreators";
|
|
import { BottomSheet } from "../../../../design/components/Sheet/native/BottomSheet.native";
|
|
import { BottomSheetScrollView } from "../../../../_bundle/Module5245";
|
|
import UserSettingsVoice from "../../../user_settings/voice/native/UserSettingsVoice";
|
|
import useChannelName from "../../../channel/useChannelName";
|
|
import useIsVoiceChannelFull, { useIsVoiceChannelLocked } from "../../../voice_calls/useIsVoiceChannelFull";
|
|
import { showInstantInviteActionSheet } from "../../../instant_invite/native/InstantInviteUtils";
|
|
import VoiceChatHeaderIcon from "../../../voice_chat/native/components/VoiceChatHeaderIcon";
|
|
import Module10795 from "../../../../_bundle/Module10795";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import AudioActionCreators from "../../../../actions/AudioActionCreators";
|
|
import SelectedChannelActionCreators from "../../../../actions/SelectedChannelActionCreators";
|
|
import useTheme from "../../../../hooks/useTheme";
|
|
import { ChannelCallMicButton } from "./ChannelCallMicButton";
|
|
import useVoiceStateForRemoteSession from "../../../game_console/hooks/useVoiceStateForRemoteSession";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import useGameConsoleAccounts from "../../../game_console/useGameConsoleAccounts";
|
|
import useMuteStates from "../../useMuteStates";
|
|
import { coerceConsoleTypeToPlatformType } from "../../../game_console/coercePlatformTypeToConsoleType";
|
|
import { beginConsoleTransfer } from "../../../game_console/native/beginConsoleTransfer";
|
|
import { LabeledActionButton, IconPosition } from "../../../stage_channels/native/components/LabeledActionBarButton";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import Module10597 from "../../../../_bundle/Module10597";
|
|
import Module10805 from "../../../../_bundle/Module10805";
|
|
let useStyles, JoinMutedButton, JoinVoiceButton;
|
|
const VoiceSettingsActionSheet = function VoiceSettingsActionSheet() {
|
|
return <BottomSheet scrollable>
|
|
<BottomSheetScrollView>
|
|
<UserSettingsVoice />
|
|
</BottomSheetScrollView>
|
|
</BottomSheet>;
|
|
};
|
|
JoinMutedButton = function JoinMutedButton(props) {
|
|
return <ChannelCallMicButton channel={props.channel} disableTint={useTheme() === "light"} isSmallSize={false} />;
|
|
};
|
|
JoinVoiceButton = function JoinVoiceButton(props) {
|
|
let stateFromStores, c18249_3, suppress;
|
|
const channel = props.channel;
|
|
stateFromStores = void 0;
|
|
c18249_3 = void 0;
|
|
suppress = void 0;
|
|
let c18249_1 = useVoiceStateForRemoteSession();
|
|
const stateFromStores2 = useStateFromStores([GameConsoleStore], () => GameConsoleStore.getAwaitingRemoteSessionInfo() != null);
|
|
stateFromStores = useStateFromStores([SessionsStore], () => {
|
|
let r3 = c18249_1?.sessionId;
|
|
if (r3 == null) {
|
|
r3 = "";
|
|
}
|
|
const sessionById = SessionsStore.getSessionById(r3);
|
|
return sessionById == null ? void 0 : sessionById.clientInfo.os;
|
|
});
|
|
const gameConsoleAccounts = useGameConsoleAccounts();
|
|
c18249_3 = gameConsoleAccounts;
|
|
const muteStates = useMuteStates(channel);
|
|
suppress = muteStates.selfMute || muteStates.mute || muteStates.suppress;
|
|
const callback = useCallback(() => {
|
|
if (stateFromStores != null) {
|
|
const r14 = coerceConsoleTypeToPlatformType(stateFromStores, c18249_3);
|
|
if (r14 != null) {
|
|
return beginConsoleTransfer(channel, r14);
|
|
}
|
|
}
|
|
const id = channel.id;
|
|
resetFocus();
|
|
if (_Module17 != null) {
|
|
const NativeModules = _Module17.NativeModules;
|
|
if (NativeModules != null) {
|
|
const KeyboardManager = NativeModules.KeyboardManager;
|
|
if (KeyboardManager != null) {
|
|
const dismissGlobalKeyboard = KeyboardManager.dismissGlobalKeyboard;
|
|
if (dismissGlobalKeyboard != null) {
|
|
dismissGlobalKeyboard.call(KeyboardManager);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (suppress && !MediaEngineStore.getSettings().mute) {
|
|
AudioActionCreators.toggleSelfMute();
|
|
}
|
|
SelectedChannelActionCreators.selectVoiceChannel(id, false, false);
|
|
}, [channel, stateFromStores, gameConsoleAccounts, suppress]);
|
|
const isVoiceChannelFull = useIsVoiceChannelFull(channel);
|
|
const isVoiceChannelLocked = useIsVoiceChannelLocked(channel);
|
|
return <LabeledActionButton disabled={isVoiceChannelFull || isVoiceChannelLocked || stateFromStores2} backgroundColor={Module712.unsafe_rawColors.GREEN_360} imageStyle={{
|
|
tintColor: Module712.unsafe_rawColors.WHITE
|
|
}} accessibilityLabel={intl.string(t["96ANUN"])} source={suppress ? Module10597 : Module10805} onPress={callback} label={isVoiceChannelLocked ? intl.string(t.TVBCKZ) : isVoiceChannelFull ? intl.string(t.rZfiNq) : suppress ? intl.string(t["Bd/Liz"]) : intl.string(t["96ANUN"])} iconPosition={IconPosition.RIGHT} />;
|
|
};
|
|
useStyles = createStyles({
|
|
spacer: {
|
|
width: 8
|
|
},
|
|
actionBarContainer: {
|
|
paddingHorizontal: 12,
|
|
paddingTop: 16,
|
|
justifyContent: "center",
|
|
alignItems: "flex-start",
|
|
flexDirection: "row",
|
|
height: CALL_ACTION_BAR_HEIGHT
|
|
}
|
|
});
|
|
export function showVoiceSettingsActionSheet(a0) {
|
|
ActionSheetActionCreators.openLazy(() => Promise.resolve(VoiceSettingsActionSheet), "voice settings", {
|
|
guildId: a0
|
|
});
|
|
}
|
|
export function ChannelCallConnectingHeader(props) {
|
|
const channel2 = props.channel;
|
|
const styles = useStyles();
|
|
const channelName = useChannelName(channel2);
|
|
const isVoiceChannelLocked = useIsVoiceChannelLocked(channel2);
|
|
const onPress = PermissionStore.can(Permissions.CREATE_INSTANT_INVITE, channel2) ? isVoiceChannelLocked ? null : () => showInstantInviteActionSheet(channel2, {
|
|
source: InstantInviteSources.VOICE_CHANNEL
|
|
}) : null;
|
|
return <>
|
|
<View style={{
|
|
width: 4
|
|
}} />
|
|
{onPress != null ? <VoiceChatHeaderIcon source={Module10795} onPress={onPress} accessibilityLabel={intl.formatToPlainString(t["dHHb/2"], {
|
|
channelName
|
|
})} /> : null}
|
|
<View style={styles.spacer} />
|
|
<View style={{
|
|
width: 4
|
|
}} />
|
|
</>;
|
|
}
|
|
export function CallConnectingActionBar(props) {
|
|
const channel3 = props.channel;
|
|
return <View style={useStyles().actionBarContainer}>
|
|
<JoinMutedButton channel={channel3} />
|
|
<JoinVoiceButton channel={channel3} />
|
|
</View>;
|
|
}
|