353 lines
14 KiB
TypeScript
353 lines
14 KiB
TypeScript
// Metro module 12025 (f12026).
|
|
import EmbeddedActivitiesStore from "../../activities/EmbeddedActivitiesStore";
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import ConnectedAccountsStore from "../../../stores/ConnectedAccountsStore";
|
|
import GuildMemberCountStore from "../../../stores/GuildMemberCountStore";
|
|
import GuildStore from "../../../stores/GuildStore";
|
|
import LocalActivityStore from "../../../stores/LocalActivityStore";
|
|
import PermissionStore from "../../../stores/PermissionStore";
|
|
import RelationshipStore from "../../../stores/RelationshipStore";
|
|
import SelectedChannelStore from "../../../stores/SelectedChannelStore";
|
|
import SelfPresenceStore from "../../../stores/SelfPresenceStore";
|
|
import VoiceStateStore from "../../../stores/VoiceStateStore";
|
|
import { PlatformTypes, UserSettingsSections } from "../../../Constants";
|
|
import { SpotifyResourceTypes, SpotifyEndpoints } from "../../spotify/SpotifyConstants";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import useAnalyticsLocations from "../../app_analytics/useAnalyticsLocations";
|
|
import { getEmbeddedActivityLocationChannelId } from "../../activities/utils/embeddedActivityLocationUtils";
|
|
import { useStateFromStores } from "../../../_bundle/defaultAreStatesEqual";
|
|
import getActivityChannelId from "../../activities/utils/getActivityChannelId";
|
|
import getActivityJoinability, { ActivityJoinability } from "../../activities/utils/getActivityJoinability";
|
|
import isEmbeddedActivity from "../../activities/utils/isEmbeddedActivity";
|
|
import { Button } from "../../../design/components/Button/native/Button.native";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import { AppsIcon } from "../../../design/components/Icon/native/redesign/generated/AppsIcon";
|
|
import handleJoinEmbeddedActivity from "../../activities/handleJoinEmbeddedActivity";
|
|
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
|
|
import GamesActionCreators_native from "../../../actions/GamesActionCreators.native";
|
|
import isListeningOnSpotify from "../../activities/utils/isListeningOnSpotify";
|
|
import { Icon } from "../../../design/void/native";
|
|
import Module7920 from "../../../_bundle/Module7920";
|
|
import { canOpenSpotifyUrl, openUrl, attributeInstall } from "../../now_playing/native/UserActivitySpotify";
|
|
import Linking from "../../../lib/native/Linking";
|
|
import getStreamURL from "../../activities/utils/getStreamURL";
|
|
import isStreaming from "../../activities/utils/isStreaming";
|
|
import ModalActionCreators from "../../../actions/ModalActionCreators";
|
|
import { getRootNavigationRef } from "../../main_tabs_v2/RootNavigationRef.native";
|
|
import { connectAndOpen } from "../../stage_channels/StageChannelModalActionCreators";
|
|
import { openGuildVoiceModal } from "../../../utils/native/PrivateChannelCallUtils";
|
|
import Platforms from "../../../lib/Platforms";
|
|
import { makeSource } from "../../../utils/AvatarUtils";
|
|
import authorizeConnection_native from "../../connections/authorizeConnection.native";
|
|
import { openUserSettings } from "../../user_settings/core/native/openUserSettings";
|
|
import isCrunchyrollActivity from "../../activities/utils/isCrunchyrollActivity";
|
|
import { getMetadata } from "../../../actions/UserActivityActionCreators";
|
|
import URLUtils from "../../../utils/URLUtils";
|
|
import { handleClick } from "../../../utils/MaskedLinkUtils";
|
|
function $mk116350($env) {
|
|
return () => Linking.openURL($env[3]);
|
|
}
|
|
let env8265 = {};
|
|
const useStyles = createStyles({
|
|
icon: {
|
|
tintColor: Module712.colors.CONTROL_SECONDARY_TEXT_DEFAULT
|
|
}
|
|
});
|
|
export function JoinActivityButton(props) {
|
|
const { user, currentUser, activity, application, onAction } = props;
|
|
const analyticsLocations = useAnalyticsLocations().analyticsLocations;
|
|
const embeddedActivityLocationChannelId = getEmbeddedActivityLocationChannelId(EmbeddedActivitiesStore.getEmbeddedActivityForUserId(user.id, application?.id)?.location);
|
|
const stateFromStores = useStateFromStores([], () => getActivityChannelId({
|
|
channelId: embeddedActivityLocationChannelId,
|
|
userId: user.id,
|
|
activity
|
|
}));
|
|
const stateFromStores2 = useStateFromStores([ChannelStore, GuildStore, GuildMemberCountStore, RelationshipStore, SelectedChannelStore, VoiceStateStore, PermissionStore, LocalActivityStore, SelfPresenceStore, EmbeddedActivitiesStore], () => getActivityJoinability({
|
|
isEmbedded: true,
|
|
user,
|
|
currentUser,
|
|
activity,
|
|
application,
|
|
channelId: stateFromStores,
|
|
ChannelStore,
|
|
GuildStore,
|
|
GuildMemberCountStore,
|
|
RelationshipStore,
|
|
SelectedChannelStore,
|
|
VoiceStateStore,
|
|
PermissionStore,
|
|
LocalActivityStore,
|
|
SelfPresenceStore,
|
|
EmbeddedActivitiesStore
|
|
}));
|
|
return isEmbeddedActivity(activity) ? application != null ? stateFromStores2 !== ActivityJoinability.CANNOT_JOIN ? <Button text={stateFromStores2 === ActivityJoinability.JOINED ? intl.string(t.DPfdsq) : intl.string(t["4i2vj+"])} icon={<AppsIcon size="sm" color="white" />} variant="active" disabled={stateFromStores2 === ActivityJoinability.JOINED} onPress={() => {
|
|
onAction({
|
|
action: "PRESS_JOIN_BUTTON"
|
|
});
|
|
handleJoinEmbeddedActivity({
|
|
applicationId: application.id,
|
|
activityChannelId: stateFromStores,
|
|
locationObject: {},
|
|
analyticsLocations
|
|
});
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
}} /> : null : null : null;
|
|
}
|
|
export function JoinGameActivityButton(props) {
|
|
const { user: user2, currentUser: currentUser2, activity: activity2, application: application2, onAction: onAction2 } = props;
|
|
const analyticsLocations2 = useAnalyticsLocations().analyticsLocations;
|
|
const application3 = {
|
|
id: application2.id,
|
|
deeplink_uri: application2.deepLinkUri
|
|
};
|
|
const stateFromStores2 = useStateFromStores([ChannelStore, GuildStore, GuildMemberCountStore, RelationshipStore, SelectedChannelStore, VoiceStateStore, PermissionStore, LocalActivityStore, SelfPresenceStore, EmbeddedActivitiesStore], () => getActivityJoinability({
|
|
user: user2,
|
|
currentUser: currentUser2,
|
|
activity: activity2,
|
|
application: application2,
|
|
channelId: null,
|
|
isEmbedded: false,
|
|
ChannelStore,
|
|
GuildStore,
|
|
GuildMemberCountStore,
|
|
RelationshipStore,
|
|
SelectedChannelStore,
|
|
VoiceStateStore,
|
|
PermissionStore,
|
|
LocalActivityStore,
|
|
SelfPresenceStore,
|
|
EmbeddedActivitiesStore
|
|
}));
|
|
return application2 == null ? null : stateFromStores2 !== ActivityJoinability.CANNOT_JOIN ? <Button text={stateFromStores2 === ActivityJoinability.JOINED ? intl.string(t.DPfdsq) : intl.string(t.VJlc0S)} variant="active" disabled={stateFromStores2 === ActivityJoinability.JOINED} onPress={() => {
|
|
onAction2({
|
|
action: "PRESS_JOIN_BUTTON"
|
|
});
|
|
GamesActionCreators_native.join({
|
|
userId: user2.id,
|
|
sessionId: activity2.session_id,
|
|
application: application3,
|
|
channelId: null,
|
|
messageId: null,
|
|
applicationActivity: activity2,
|
|
source: "UserProfile",
|
|
analyticsLocations: analyticsLocations2
|
|
});
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
}} /> : null;
|
|
}
|
|
export function PlayOnSpotifyButton(props) {
|
|
const { activity: activity4, onAction: onAction3 } = props;
|
|
const styles = useStyles();
|
|
const sync_id = activity4.sync_id;
|
|
return isListeningOnSpotify(activity4) ? sync_id != null ? <Button text={intl.formatToPlainString(t.LEgD7t, {
|
|
platform: activity4.name
|
|
})} icon={<Icon size={Icon.Sizes.SMALL} source={Module7920} disableColor style={styles.icon} />} variant="secondary" onPress={async () => {
|
|
let r64;
|
|
let c27221_3 = 0;
|
|
let c30478_0;
|
|
try {
|
|
c30478_0 = void 0;
|
|
onAction3({
|
|
action: "PRESS_PLAY_ON_SPOTIFY_BUTTON"
|
|
});
|
|
c27221_3 = 1;
|
|
c30478_0 = await canOpenSpotifyUrl();
|
|
if (c30478_0) {
|
|
r64 = openUrl(c30478_0, SpotifyResourceTypes.TRACK, sync_id);
|
|
} else {
|
|
attributeInstall();
|
|
r64 = Linking.openURL(SpotifyEndpoints.APP_STORE);
|
|
}
|
|
c27221_3 = 0;
|
|
} catch ($e) {
|
|
let r7 = $e;
|
|
if (c27221_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c27221_3 = 0;
|
|
} catch ($e) {
|
|
r7 = $e;
|
|
if (c27221_3 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
return r64;
|
|
}} /> : null : null;
|
|
}
|
|
export function WatchActivityButton(props) {
|
|
const { activity: activity4, onAction: onAction4 } = props;
|
|
const streamURL = getStreamURL(activity4);
|
|
let c19344_1 = streamURL;
|
|
return isStreaming(activity4) ? streamURL != null ? <Button text={intl.string(t.I6JG46)} variant="secondary" onPress={() => {
|
|
onAction4({
|
|
action: "PRESS_WATCH_BUTTON"
|
|
});
|
|
Linking.openURL(c19344_1);
|
|
}} /> : null : null;
|
|
}
|
|
export function VoiceChannelButtons(props) {
|
|
let r52, isInChannel, text;
|
|
let channel, onAction5, newestAnalyticsLocation, isGuildStageVoice;
|
|
L17: {
|
|
channel = props.channel;
|
|
isInChannel = props.isInChannel;
|
|
onAction5 = props.onAction;
|
|
newestAnalyticsLocation = void 0;
|
|
isGuildStageVoice = void 0;
|
|
newestAnalyticsLocation = useAnalyticsLocations().newestAnalyticsLocation;
|
|
isGuildStageVoice = channel.isGuildStageVoice();
|
|
const isDM = channel.isDM();
|
|
if (isInChannel) {
|
|
L16: {
|
|
if (!isDM && !channel.isGroupDM()) {
|
|
if (isGuildStageVoice) {
|
|
r52 = intl.string(t.Acqcot);
|
|
break L16;
|
|
}
|
|
r52 = intl.string(t.BXxdl7);
|
|
} else {
|
|
r52 = intl.string(t["7hwn2A"]);
|
|
}
|
|
}
|
|
text = r52;
|
|
} else {
|
|
if (!isDM && !channel.isGroupDM()) {
|
|
if (isGuildStageVoice) {
|
|
text = intl.string(t["7vb2cc"]);
|
|
break L17;
|
|
}
|
|
text = intl.string(t["96ANUN"]);
|
|
break L17;
|
|
}
|
|
text = intl.string(t.ozoE2A);
|
|
}
|
|
}
|
|
return <Button text={text} variant={isInChannel ? "secondary" : "active"} grow onPress={() => {
|
|
onAction5({
|
|
action: "PRESS_JOIN_CALL_BUTTON"
|
|
});
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
ModalActionCreators.popAll();
|
|
const rootNavigationRef = getRootNavigationRef();
|
|
if ((rootNavigationRef == null ? void 0 : rootNavigationRef.isReady()) === true && rootNavigationRef.getCurrentRoute()?.name === "you") {
|
|
rootNavigationRef.goBack();
|
|
}
|
|
if (isGuildStageVoice) {
|
|
connectAndOpen(channel);
|
|
} else {
|
|
openGuildVoiceModal(channel, newestAnalyticsLocation);
|
|
}
|
|
}} />;
|
|
}
|
|
export function ConnectPlatformButton(props) {
|
|
let c19346_3;
|
|
const { type, onAction: onAction6 } = props;
|
|
c19346_3 = void 0;
|
|
const styles = useStyles();
|
|
const newestAnalyticsLocation2 = useAnalyticsLocations().newestAnalyticsLocation;
|
|
if (useStateFromStores([ConnectedAccountsStore], () => ConnectedAccountsStore.getAccount(null, type) != null)) {
|
|
return null;
|
|
}
|
|
const r27 = Platforms.get(type);
|
|
c19346_3 = r27;
|
|
return <Button text={intl.formatToPlainString(t.XWSHTb, {
|
|
platform: r27.name
|
|
})} icon={<Icon size={Icon.Sizes.SMALL} source={makeSource(r27.icon.whitePNG)} disableColor style={styles.icon} />} variant="secondary" onPress={() => {
|
|
onAction6({
|
|
action: type === PlatformTypes.PLAYSTATION ? "PRESS_CONNECT_PLAYSTATION_BUTTON" : "PRESS_CONNECT_XBOX_BUTTON"
|
|
});
|
|
authorizeConnection_native({
|
|
platformType: c19346_3.type,
|
|
location: newestAnalyticsLocation2,
|
|
onClose: () => openUserSettings({
|
|
screen: UserSettingsSections.CONNECTIONS
|
|
})
|
|
});
|
|
}} />;
|
|
}
|
|
export function CustomActivityButton(props) {
|
|
const { user: user3, activity: activity3, index, onAction: onAction7 } = props;
|
|
return activity3.buttons == null ? null : index >= activity3.buttons.length ? null : <Button text={isCrunchyrollActivity(activity3) ? intl.string(t.I6JG46) : activity3.buttons[index]} variant="secondary" onPress={async () => {
|
|
let c27222_0, c27222_1, c27222_2;
|
|
let c27222_3 = 0;
|
|
const r12 = void 0;
|
|
const r11 = env8265;
|
|
L24: {
|
|
L21: {
|
|
L23: {
|
|
try {
|
|
let env30479;
|
|
c27222_1 = r12;
|
|
const r28 = env30479 = {
|
|
$parent: r11
|
|
};
|
|
c27222_0 = r28;
|
|
env30479[0] = void 0;
|
|
env30479[1] = void 0;
|
|
env30479[2] = void 0;
|
|
env30479[3] = void 0;
|
|
onAction7({
|
|
action: "PRESS_CUSTOM_BUTTON"
|
|
});
|
|
c27222_3 = 1;
|
|
env30479[0] = await getMetadata(activity3, user3.id);
|
|
if (env30479[0].button_urls.length <= index) {
|
|
c27222_3 = 0;
|
|
break L24;
|
|
}
|
|
env30479[1] = env30479[0].button_urls[index];
|
|
if (typeof env30479[1] !== "string") {
|
|
c27222_3 = 0;
|
|
break L23;
|
|
}
|
|
env30479[2] = URLUtils.safeParseWithQuery(env30479[1]);
|
|
if (env30479[2]?.protocol != null) {
|
|
if (env30479[2]?.hostname != null) {
|
|
const r88 = c27222_0;
|
|
env30479[3] = URLUtils.format(env30479[2]);
|
|
handleClick({
|
|
href: env30479[3],
|
|
onConfirm: $mk116350(r88),
|
|
trusted: false
|
|
});
|
|
c27222_3 = 0;
|
|
break L21;
|
|
}
|
|
}
|
|
c27222_3 = 0;
|
|
} catch ($e) {
|
|
const r26 = $e;
|
|
let r7 = r26;
|
|
c27222_2 = r26;
|
|
if (c27222_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c27222_3 = 0;
|
|
break L21;
|
|
} catch (r110) {
|
|
r7 = r110;
|
|
c27222_2 = r110;
|
|
if (c27222_3 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
return void 0;
|
|
}
|
|
return void 0;
|
|
}
|
|
return void 0;
|
|
}
|
|
}} />;
|
|
}
|