256 lines
15 KiB
TypeScript
256 lines
15 KiB
TypeScript
// Metro module 15937 (f15938).
|
|
import { useCallback, memo } from "react";
|
|
import EmbeddedActivitiesStore from "../../../activities/EmbeddedActivitiesStore";
|
|
import ChannelRTCStore from "../../../calls/ChannelRTCStore";
|
|
import ChannelCallLifecycleStore from "../../../video_calls/native/ChannelCallLifecycleStore";
|
|
import AuthenticationStore from "../../../../stores/AuthenticationStore";
|
|
import ChannelStore from "../../../../stores/ChannelStore";
|
|
import MediaEngineStore from "../../../../stores/MediaEngineStore";
|
|
import PermissionStore from "../../../../stores/PermissionStore";
|
|
import UserStore from "../../../../stores/UserStore";
|
|
import SortedVoiceStateStore from "../../../../stores/views/SortedVoiceStateStore";
|
|
import { AnalyticsSections, Permissions, RPC_APPLICATION_LOGGING_CATEGORY } from "../../../../Constants";
|
|
import { isStreamParticipant } from "../../../calls/CallConstants";
|
|
import { SECURE_FRAMES_CALL_VERIFICATION_BOTTOM_SHEET_KEY } from "../../../rtc/SecureFramesConstants";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import { useStateFromStores, useStateFromStoresArray } from "../../../../_bundle/Module589";
|
|
import getChannelInfoSubtitle from "../utils/getChannelInfoSubtitle";
|
|
import useChannelName from "../../../channel/useChannelName";
|
|
import { useIsSecureFramesUIEnabled } from "../../../rtc/hooks/useIsSecureFramesUIEnabled";
|
|
import { useIsCallSecureFramesVerified } from "../../../rtc/hooks/useIsSecureFramesVerified";
|
|
import NativeView from "../../../core/native/NativeView";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
import { ShieldLockIcon } from "../../../../design/components/Icon/native/redesign/generated/ShieldLockIcon";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import { LockIcon } from "../../../../design/components/Icon/native/redesign/generated/LockIcon";
|
|
import { stringify } from "../../../debug/LogAggregator";
|
|
import ToastActionCreators from "../../../toast/native/ToastActionCreators";
|
|
import { closeVoicePanelSettingsActionSheet } from "./VoicePanelSettingsActionCreators";
|
|
import { showShareActionSheet } from "../../../action_sheet/native/showShareActionSheet";
|
|
import { TableRow } from "../../../../design/components/TableRow/native/TableRow.native";
|
|
import { TableRowIcon } from "../../../../design/components/TableRow/native/TableRowIcon.native";
|
|
import { WrenchIcon } from "../../../../design/components/Icon/native/redesign/generated/WrenchIcon";
|
|
import Module7690 from "../../../../_bundle/Module7690";
|
|
import { TableRowArrow } from "../../../../design/components/TableRow/native/TableRowArrow.native";
|
|
import Dispatcher from "../../../../Dispatcher";
|
|
import { TableSwitchRow } from "../../../../design/components/TableRow/native/TableSwitchRow.native";
|
|
import { DeveloperMode } from "../../../user_settings/UserSettings";
|
|
import AudioActionCreators from "../../../../actions/AudioActionCreators";
|
|
import ChannelRTCActionCreators from "../../../../actions/ChannelRTCActionCreators";
|
|
import ChannelSettingsActionCreators from "../../../../actions/ChannelSettingsActionCreators";
|
|
import { showVoiceSettingsActionSheet } from "../../../video_calls/native/components/ChannelCallConnectingScreen";
|
|
import ActionSheetActionCreators from "../../../action_sheet/native/ActionSheetActionCreators";
|
|
import SecureFramesPlatformUtils_native from "../../../rtc/SecureFramesPlatformUtils.native";
|
|
import { useIsCallRTCConnectionEmpty, useIsStreamRTCConnectionEmpty } from "../../../rtc/hooks/useIsEmptyRTCConnection";
|
|
import useCanSetVoiceChannelStatus from "../../../calls/useCanSetVoiceChannelStatus";
|
|
import { useCanInviteMembers } from "../hooks/useCanInviteMembers";
|
|
import { useInviteMembersCallback } from "../hooks/useInviteMembersCallback";
|
|
import useShowChannelOptInNotice from "../../../opt_in_channels/useShowChannelOptInNotice";
|
|
import { VoicePanelFormSection, MemberRowItem } from "../shared/FormComponents";
|
|
import VoicePanelChannelOptInNotice from "../shared/VoicePanelChannelOptInNotice";
|
|
import { SettingsIcon } from "../../../../design/components/Icon/native/redesign/generated/SettingsIcon";
|
|
import Module15942 from "../../../../_bundle/Module15942";
|
|
import { HeadphonesSlashIcon } from "../../../../design/components/Icon/native/redesign/generated/HeadphonesSlashIcon";
|
|
import Module15943 from "../../../../_bundle/Module15943";
|
|
import { VideoIcon } from "../../../../design/components/Icon/native/redesign/generated/VideoIcon";
|
|
import Module10744 from "../../../../_bundle/Module10744";
|
|
import { GroupPlusIcon } from "../../../../design/components/Icon/native/redesign/generated/GroupPlusIcon";
|
|
import Module10223 from "../../../../_bundle/Module10223";
|
|
let useStyles, ShareActivityLogsButton, ActivityDebugToggle;
|
|
const VoicePanelSettingsOverviewHeader = function VoicePanelSettingsOverviewHeader(props) {
|
|
const { guildId, channelId } = props;
|
|
const styles = useStyles();
|
|
const stateFromStores5 = useStateFromStores([SortedVoiceStateStore], () => {
|
|
const voiceStatesForChannelAlt = SortedVoiceStateStore.getVoiceStatesForChannelAlt(channelId, guildId);
|
|
const r19 = voiceStatesForChannelAlt.slice(0, 2).map((item) => item.user);
|
|
return getChannelInfoSubtitle(guildId, channelId, r19, voiceStatesForChannelAlt.length - r19.length);
|
|
});
|
|
const channelName = useChannelName(useStateFromStores([ChannelStore], () => ChannelStore.getChannel(channelId), [channelId]));
|
|
let r39 = useIsSecureFramesUIEnabled({
|
|
channelId
|
|
});
|
|
let r13 = useIsCallSecureFramesVerified({
|
|
channelId
|
|
});
|
|
const r57 = [<Text style={styles.channelTitle} variant="heading-lg/bold" lineClamp={1} accessibilityRole="header">{channelName}</Text>, ,];
|
|
if (r13) {
|
|
r13 = <ShieldLockIcon style={styles.secureFramesIcon} size="xs" accessibilityLabel={intl.string(t.mR9cf3)} />;
|
|
}
|
|
r57[1] = r13;
|
|
const r71 = [<NativeView style={styles.channelTitleWrapper}>{r57}</NativeView>, <Text style={styles.channelSubtitle} variant="text-sm/medium" accessibilityRole="summary">{stateFromStores5}</Text>, ,];
|
|
if (r39) {
|
|
r39 = <NativeView style={styles.secureFrames}>
|
|
<LockIcon size="xxs" color="status-positive" />
|
|
<Text variant="text-xs/medium" color="status-positive">
|
|
{intl.string(t["3BogKe"])}
|
|
</Text>
|
|
</NativeView>;
|
|
}
|
|
r71[2] = r39;
|
|
return <NativeView style={styles.headerContainer}>{r71}</NativeView>;
|
|
};
|
|
ShareActivityLogsButton = function ShareActivityLogsButton() {
|
|
return <TableRow onPress={useCallback(() => {
|
|
const message = stringify([RPC_APPLICATION_LOGGING_CATEGORY]);
|
|
if (message === "") {
|
|
ToastActionCreators.open({
|
|
key: "EMBEDDED_ACTIVITIES_SHARE_EMPTY_LOGS_ERROR_MESSAGE",
|
|
content: intl.string(t["i+9VWy"])
|
|
});
|
|
} else {
|
|
closeVoicePanelSettingsActionSheet();
|
|
showShareActionSheet({
|
|
message
|
|
}, "Activity Logs");
|
|
}
|
|
}, [])} icon={<TableRowIcon IconComponent={WrenchIcon} source={Module7690} />} label={intl.string(t.iQzQs3)} trailing={<TableRowArrow />} />;
|
|
};
|
|
ActivityDebugToggle = function ActivityDebugToggle() {
|
|
const stateFromStores5 = useStateFromStores([ChannelCallLifecycleStore], () => ChannelCallLifecycleStore.getShowActivitiesDebugOverlay());
|
|
const callback = useCallback((a0) => {
|
|
Dispatcher.dispatch({
|
|
type: "EMBEDDED_ACTIVITY_SET_DEBUG_OVERLAY_VISIBILITY",
|
|
visible: a0
|
|
});
|
|
}, []);
|
|
return <TableSwitchRow icon={<TableRowIcon IconComponent={WrenchIcon} source={Module7690} />} accessibilityHint={intl.string(t["qv5/SP"])} value={stateFromStores5} onValueChange={callback} label={intl.string(t["qv5/SP"])} />;
|
|
};
|
|
useStyles = createStyles({
|
|
headerContainer: {
|
|
alignItems: "center"
|
|
},
|
|
channelTitleWrapper: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
marginTop: 8
|
|
},
|
|
channelTitle: {
|
|
textAlign: "center"
|
|
},
|
|
channelSubtitle: {
|
|
marginTop: 4,
|
|
marginHorizontal: 16,
|
|
textAlign: "center"
|
|
},
|
|
secureFrames: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH,
|
|
borderRadius: Module712.radii.sm,
|
|
marginTop: 8,
|
|
padding: 4,
|
|
gap: 4
|
|
},
|
|
secureFramesIcon: {
|
|
marginStart: 4
|
|
}
|
|
});
|
|
const r73 = memo(function VoicePanelSettingsOverview(props) {
|
|
let stateFromStores2, stateFromStores3, stateFromStores4, isSecureFramesUIEnabled;
|
|
const { guildId: guildId2, channelId: channelId2 } = props;
|
|
stateFromStores2 = void 0;
|
|
stateFromStores3 = void 0;
|
|
stateFromStores4 = void 0;
|
|
isSecureFramesUIEnabled = void 0;
|
|
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(channelId2));
|
|
const setting = DeveloperMode.useSetting();
|
|
stateFromStores2 = useStateFromStores([SortedVoiceStateStore], () => SortedVoiceStateStore.getVoiceStatesForChannelAlt(channelId2, guildId2));
|
|
const stateFromStoresArray = useStateFromStoresArray([UserStore], () => {
|
|
if (stateFromStores != null && stateFromStores.isPrivate()) {
|
|
const set = new Set(stateFromStores2.map((item) => item.user.id));
|
|
const r30 = [];
|
|
for (const recipient of stateFromStores.recipients) {
|
|
const user = UserStore.getUser(recipient);
|
|
if (!(user == null || set.has(recipient))) {
|
|
r30.push(user);
|
|
}
|
|
}
|
|
return r30;
|
|
}
|
|
return [];
|
|
}, [stateFromStores, stateFromStores2]);
|
|
const stateFromStores6 = useStateFromStores([MediaEngineStore], () => MediaEngineStore.isSelfDeaf());
|
|
const callback5 = useCallback(() => {
|
|
AudioActionCreators.toggleSelfDeaf();
|
|
}, []);
|
|
stateFromStores3 = useStateFromStores([ChannelRTCStore], () => ChannelRTCStore.getVoiceParticipantsHidden(channelId2));
|
|
stateFromStores4 = useStateFromStores([ChannelRTCStore, AuthenticationStore], () => {
|
|
const selectedParticipant = ChannelRTCStore.getSelectedParticipant(channelId2);
|
|
return isStreamParticipant(selectedParticipant) ? selectedParticipant.stream.ownerId !== AuthenticationStore.getId() ? selectedParticipant.id : null : null;
|
|
});
|
|
const callback4 = useCallback(() => {
|
|
ChannelRTCActionCreators.toggleVoiceParticipantsHidden(channelId2, !stateFromStores3);
|
|
}, [channelId2, stateFromStores3]);
|
|
const callback6 = useCallback(() => {
|
|
closeVoicePanelSettingsActionSheet();
|
|
ChannelSettingsActionCreators.open(channelId2);
|
|
}, [channelId2]);
|
|
const callback2 = useCallback(() => {
|
|
closeVoicePanelSettingsActionSheet();
|
|
showVoiceSettingsActionSheet(guildId2);
|
|
}, [guildId2]);
|
|
const callback3 = useCallback(() => {
|
|
ActionSheetActionCreators.openLazy(import("../../../rtc/native/SecureFramesCallVerificationBottomSheet"), SECURE_FRAMES_CALL_VERIFICATION_BOTTOM_SHEET_KEY, {
|
|
channelId: channelId2
|
|
});
|
|
}, [channelId2]);
|
|
const callback = useCallback(() => {
|
|
if (stateFromStores4 != null) {
|
|
SecureFramesPlatformUtils_native.openSecureFramesStreamVerification(stateFromStores4, channelId2);
|
|
}
|
|
}, [channelId2, stateFromStores4]);
|
|
const isCallRTCConnectionEmpty = useIsCallRTCConnectionEmpty();
|
|
const isStreamRTCConnectionEmpty = useIsStreamRTCConnectionEmpty(stateFromStores4);
|
|
const stateFromStores7 = useStateFromStores([EmbeddedActivitiesStore], () => EmbeddedActivitiesStore.getCurrentEmbeddedActivity() != null, []);
|
|
const canSetVoiceChannelStatus = useCanSetVoiceChannelStatus(stateFromStores);
|
|
const stateFromStores5 = useStateFromStores([PermissionStore], () => PermissionStore.canWithPartialContext(Permissions.MANAGE_CHANNELS, {
|
|
channelId: channelId2
|
|
}), [channelId2]);
|
|
const canInviteMembers = useCanInviteMembers(channelId2);
|
|
const inviteMembersCallback = useInviteMembersCallback(channelId2);
|
|
const showChannelOptInNotice = useShowChannelOptInNotice(stateFromStores);
|
|
let r18 = useIsSecureFramesUIEnabled({
|
|
channelId: channelId2
|
|
});
|
|
isSecureFramesUIEnabled = r18;
|
|
const r135 = [<VoicePanelSettingsOverviewHeader guildId={guildId2} channelId={channelId2} />, showChannelOptInNotice ? <VoicePanelFormSection hasIcons={false}>
|
|
<VoicePanelChannelOptInNotice channel={stateFromStores} analyticsSection={AnalyticsSections.CHANNEL_ACTION_SHEET} />
|
|
</VoicePanelFormSection> : null, (stateFromStores5 ? stateFromStores5 : canSetVoiceChannelStatus) && <VoicePanelFormSection hasIcons={false}>
|
|
{stateFromStores5 && <TableRow onPress={callback6} label={intl.string(t.XPDhcc)} subLabel={intl.string(t.w7ZEot)} trailing={<TableRowArrow />} />}
|
|
</VoicePanelFormSection>, , , ,];
|
|
const r220 = [<TableRow onPress={callback2} icon={<TableRowIcon IconComponent={SettingsIcon} source={Module15942} />} label={intl.string(t.NiTd0e)} subLabel={intl.string(t["16SG+O"])} trailing={<TableRowArrow />} />, <TableSwitchRow icon={<TableRowIcon IconComponent={HeadphonesSlashIcon} source={Module15943} />} accessibilityHint={intl.string(t.wjcRFX)} value={stateFromStores6} onValueChange={callback5} label={intl.string(t.wjcRFX)} subLabel={intl.string(t.M3VN2U)} />, <TableSwitchRow icon={<TableRowIcon IconComponent={VideoIcon} source={Module10744} />} accessibilityHint={intl.string(t.ZMTRyc)} value={stateFromStores3} onValueChange={callback4} label={intl.string(t.ZMTRyc)} subLabel={intl.string(t.MlpCFS)} />, (isSecureFramesUIEnabled ? stateFromStores4 == null : isSecureFramesUIEnabled) && !isCallRTCConnectionEmpty && <TableRow onPress={callback3} icon={<TableRowIcon IconComponent={LockIcon} source={Module15942} />} label={intl.string(t.cTQI5t)} subLabel={intl.string(t.Etxti2)} trailing={<TableRowArrow />} />, ,];
|
|
if (isSecureFramesUIEnabled) {
|
|
r18 = stateFromStores4 != null;
|
|
}
|
|
if (r18) {
|
|
r18 = !isStreamRTCConnectionEmpty;
|
|
}
|
|
if (r18) {
|
|
r18 = <TableRow onPress={callback} icon={<TableRowIcon IconComponent={LockIcon} source={Module15942} />} label={intl.string(t.QogHld)} subLabel={intl.string(t["j5+1ed"])} trailing={<TableRowArrow />} />;
|
|
}
|
|
r220[4] = r18;
|
|
r135[3] = <VoicePanelFormSection hasIcons>{r220}</VoicePanelFormSection>;
|
|
r135[4] = (stateFromStores2.length > 0 || canInviteMembers) && <VoicePanelFormSection title={`${intl.formatToPlainString(t.AWmdd9, {
|
|
count: `${stateFromStores2.length}`
|
|
})}`} hasIcons>
|
|
{canInviteMembers ? <TableRow onPress={inviteMembersCallback} icon={<TableRowIcon IconComponent={GroupPlusIcon} source={Module10223} />} label={intl.string(t["f1+QIK"])} trailing={<TableRowArrow />} /> : null}
|
|
{stateFromStores2.map((item) => {
|
|
let nick = item.nick;
|
|
if (nick == null) {
|
|
nick = void 0;
|
|
}
|
|
return <MemberRowItem key={item.user.id} user={item.user} selfStream={item.voiceState.selfStream} nick={nick} channelId={channelId2} guildId={guildId2} showSecureFramesUI={isSecureFramesUIEnabled} />;
|
|
})}
|
|
{stateFromStoresArray.map((item) => <MemberRowItem key={item.id} user={item} channelId={channelId2} guildId={guildId2} notConnected showRing />)}
|
|
</VoicePanelFormSection>;
|
|
r135[5] = setting ? <VoicePanelFormSection title={intl.string(t.J6rqB7)} hasIcons>
|
|
{stateFromStores7 ? <ShareActivityLogsButton /> : null}
|
|
<ActivityDebugToggle />
|
|
</VoicePanelFormSection> : null;
|
|
return <>{r135}</>;
|
|
});
|
|
export default r73;
|
|
export { VoicePanelSettingsOverviewHeader };
|