Files
discord-decomp/modules/messages/native/handlers/handleMessagesTapChannel.tsx
T
2026-11-01 12:12:55 +02:00

294 lines
13 KiB
TypeScript

// Metro module 9990 (f9991).
import { isGuildVocalChannelType } from "../../../../records/ChannelRecord";
import { isGuildLurker } from "../../../../records/GuildRecord";
import ChannelStore from "../../../../stores/ChannelStore";
import GuildMemberStore from "../../../../stores/GuildMemberStore";
import GuildRoleStore from "../../../../stores/GuildRoleStore";
import GuildStore from "../../../../stores/GuildStore";
import PermissionStore from "../../../../stores/PermissionStore";
import { ChannelTypes, GuildFeatures, Permissions, Routes } from "../../../../Constants";
import { StaticChannelRoute } from "../../../channel/ChannelConstants";
import { GuildOnboardingTab } from "../../../guild_onboarding/GuildOnboardingPromptsConstants";
import { CHANNELS_AND_ROLES_MODAL_KEY } from "../../../guild_onboarding/native/GuildOnboardingConstants";
import { startLurking } from "../../../../utils/GuildDiscoveryUtils";
import LinkAnalyticsUtils from "../../../links/LinkAnalyticsUtils";
import { isStaticRouteIconType } from "../../../markup/MarkupRulesUtils";
import ModalActionCreators from "../../../../actions/ModalActionCreators";
import "../../../../_bundle/asyncRequire";
import safeTransitionTo_native from "../../../links/safeTransitionTo.native";
import ActionSheetActionCreators from "../../../action_sheet/native/ActionSheetActionCreators";
import { assertNever } from "../../../../utils/GlobalUtils";
import { canViewChannel } from "../../../links/LinkUtils";
import { openChannelCallModal } from "../../../../utils/native/PrivateChannelCallUtils";
import SelectedChannelActionCreators from "../../../../actions/SelectedChannelActionCreators";
const maybeStartLurking = async function maybeStartLurking(c26586_0, c26586_1, channelId, messageId) {
let c26586_6 = 0;
L13: {
L10: {
try {
if (c26586_0 != null && !isGuildLurker(c26586_0)) {
break L10;
}
c26586_6 = 1;
await startLurking(c26586_1, {}, {
channelId,
messageId
});
c26586_6 = 0;
break L13;
} catch ($e) {
let r27 = $e;
if (c26586_6 !== 0) {
while (true) {
try {
c26586_6 = 0;
} catch ($e) {
r27 = $e;
if (c26586_6 === 0) {
break;
}
continue;
}
return false;
}
}
throw r27;
}
}
return false;
}
return true;
};
export async function handleMessagesTapChannel(c26587_0) {
let c26587_2;
let c30175_0, c30175_1, c30175_2, c30175_3, c30175_4, c30175_5, c30175_6, c30175_7, c30175_8, c30175_9, c30175_10, c30175_11;
L30: {
L91: {
L75: {
L68: {
L57: {
L48: {
L47: {
L44: {
L41: {
L38: {
c26587_2 = void 0;
c30175_0 = void 0;
c30175_1 = void 0;
c30175_2 = void 0;
c30175_3 = void 0;
c30175_0 = c26587_0.data;
const navigationReplace = c26587_0.navigationReplace;
if (navigationReplace !== void 0) {
c30175_1 = navigationReplace;
c30175_2 = c26587_0.onBeforeNavigate;
c30175_3 = c26587_0.dismissKeyboard;
c30175_4 = void 0;
c30175_5 = void 0;
c30175_6 = void 0;
c30175_7 = void 0;
c30175_8 = void 0;
c30175_9 = void 0;
c30175_10 = void 0;
c30175_11 = void 0;
} else {
c30175_1 = false;
c30175_2 = c26587_0.onBeforeNavigate;
c30175_3 = c26587_0.dismissKeyboard;
c30175_4 = void 0;
c30175_5 = void 0;
c30175_6 = void 0;
c30175_7 = void 0;
c30175_8 = void 0;
c30175_9 = void 0;
c30175_10 = void 0;
c30175_11 = void 0;
}
await void 0;
c30175_4 = c30175_0.channelId;
c30175_5 = c30175_0.guildId;
c30175_6 = c30175_0.messageId;
c30175_7 = c30175_4 != null ? ChannelStore.getChannel(c30175_4) : null;
c30175_8 = GuildStore.getGuild(c30175_5);
LinkAnalyticsUtils.trackDiscordLinkClicked({
guildId: c30175_5,
channelId: c30175_4,
messageId: c30175_6
});
if (c30175_5 != null && c30175_4 != null) {
if (isStaticRouteIconType(c30175_4)) {
if (c30175_8 == null) {
break L48;
}
const r107 = c30175_4;
if (r107 === "browse") {
if (c30175_8.features.has(GuildFeatures.COMMUNITY)) {
ModalActionCreators.pushLazy(import("../../../guild_onboarding/native/ChannelsAndRolesModal"), {
guildId: c30175_5,
defaultTab: GuildOnboardingTab.BROWSE
}, CHANNELS_AND_ROLES_MODAL_KEY);
break L30;
}
break L47;
}
if (r107 === "customize") {
if (c30175_8.features.has(GuildFeatures.COMMUNITY)) {
ModalActionCreators.pushLazy(import("../../../guild_onboarding/native/ChannelsAndRolesModal"), {
guildId: c30175_5,
defaultTab: GuildOnboardingTab.CUSTOMIZE
}, CHANNELS_AND_ROLES_MODAL_KEY);
break L30;
}
break L44;
}
if (r107 !== "home" && r107 !== "guide") {
if (r107 === "linked-roles") {
c30175_9 = c30175_6;
if (c30175_9 != null) {
c30175_10 = GuildMemberStore.getSelfMember(c30175_5);
if (c30175_10 == null) {
break L38;
}
c30175_11 = GuildRoleStore.getRole(c30175_5, c30175_9);
if (c30175_11 != null) {
if (!c30175_10.roles.includes(c30175_11.id)) {
ActionSheetActionCreators.openLazy(import("../../../connections/native/GuildRoleConnectionsConnectAccountsActionSheet"), `GuildRoleConnectionsConnectAccountsActionSheet-${c30175_11.id}`, {
role: c30175_11,
guildId: c30175_5
});
break L30;
}
}
ModalActionCreators.pushLazy(import("../../../connections/native/GuildRoleConnectionsModal"), {
guildId: c30175_5
});
break L30;
}
ModalActionCreators.pushLazy(import("../../../connections/native/GuildRoleConnectionsModal"), {
guildId: c30175_5
});
break L30;
}
assertNever(c30175_4);
break L30;
}
if (c30175_8.features.has(GuildFeatures.COMMUNITY)) {
safeTransitionTo_native(Routes.CHANNEL(c30175_5, StaticChannelRoute.GUILD_HOME), {
navigationReplace: c30175_1,
openChannel: true
});
break L30;
}
break L41;
}
}
if (c30175_6 != null && c30175_7 != null) {
if (!c30175_7.isPrivate()) {
if (await (0, maybeStartLurking)(c30175_8, c30175_7.guild_id, c30175_7.id, c30175_6)) {
break L57;
}
}
const r303 = c30175_2;
if (r303 != null) {
r303();
}
safeTransitionTo_native(Routes.CHANNEL(c30175_7.guild_id, c30175_7.id, c30175_6), {
navigationReplace: c30175_1,
openChannel: true
});
break L30;
}
if (c30175_7 != null && c30175_5 != null) {
if (!c30175_7.isPrivate()) {
if (await (0, maybeStartLurking)(c30175_8, c30175_5, c30175_7.id, c30175_6)) {
break L68;
}
}
if ((0, isGuildVocalChannelType)(c30175_7.type)) {
if (canViewChannel(c30175_7)) {
if (c30175_7.type === ChannelTypes.GUILD_STAGE_VOICE) {
if (!PermissionStore.can(Permissions.CONNECT, c30175_7)) {
break L75;
}
}
const r402 = c30175_3;
if (r402 != null) {
r402();
}
const r414 = c30175_2;
if (r414 != null) {
r414();
}
openChannelCallModal(c30175_7);
break L30;
}
}
const r384 = c30175_2;
if (r384 != null) {
r384();
}
safeTransitionTo_native(Routes.CHANNEL(c30175_5, c30175_7.id), {
navigationReplace: c30175_1,
openChannel: true
});
break L30;
}
if (c30175_4 != null && c30175_5 != null) {
if (await (0, maybeStartLurking)(c30175_8, c30175_5, c30175_4, c30175_6)) {
break L91;
}
const r471 = c30175_2;
if (r471 != null) {
r471();
}
safeTransitionTo_native(Routes.CHANNEL(c30175_5, c30175_4, c30175_6), {
navigationReplace: c30175_1,
openChannel: true
});
break L30;
}
if (c30175_7 != null && c30175_7.isPrivate()) {
const r499 = c30175_3;
if (r499 != null) {
r499();
}
const r501 = c30175_2;
if (r501 != null) {
r501();
}
SelectedChannelActionCreators.selectVoiceChannel(c30175_4);
break L30;
}
if (!(c30175_4 != null && c30175_5 == null)) {
break L30;
}
const r516 = c30175_2;
if (r516 != null) {
r516();
}
safeTransitionTo_native(Routes.CHANNEL(c30175_5, c30175_4, c30175_6), {
navigationReplace: c30175_1,
openChannel: true
});
break L30;
}
return void 0;
}
return void 0;
}
return void 0;
}
return void 0;
}
return void 0;
}
return void 0;
}
return void 0;
}
return void 0;
}
return void 0;
}
}