Files
discord-decomp/modules/routing/convertRouteToNavigation.native.tsx
T
2026-11-01 12:12:55 +02:00

130 lines
4.3 KiB
TypeScript

// Metro module 10877 (f10878).
import { Routes } from "../../Constants";
import { getChatLayout } from "../chat/native/useChatLayout";
import { coerceGuildsRoute, navigateToRootTab, navigateToChannel, navigateToMemberVerification, resetToAuthRoute } from "../main_tabs_v2/helpers/NavigationRouteUtils.native";
import { getRootNavigationRef } from "../main_tabs_v2/RootNavigationRef.native";
import { matchPath } from "./matchPathCompat";
import { RouteParam } from "./RouteUtils";
export function convertRouteToNavigation(a0) {
let r89;
const pathname = a0.pathname;
const rootNavigationRef = getRootNavigationRef();
if (rootNavigationRef != null && rootNavigationRef.isReady()) {
if (pathname.startsWith("/channels/")) {
if (matchPath(pathname, {
path: `${Routes.CHANNEL(RouteParam.guildId(), RouteParam.channelId({
optional: true
}))}${Routes.VOICE_CHAT_CHANNEL_PARTIAL(RouteParam.guildId({
name: "voiceGuildId"
}), RouteParam.channelId({
name: "voiceChannelId"
}), ":voiceMessageId?")}`
}) != null) {
return true;
}
const r75 = matchPath(pathname, {
path: Routes.CHANNEL(RouteParam.guildId(), RouteParam.channelId({
optional: true
}), ":messageId?")
});
if (r75 != null) {
L39: {
const params = r75.params;
const { channelId, guildId, messageId } = params;
const { navigationReplace, openChannel } = a0;
if (getChatLayout().isChatLockedOpen) {
if (channelId != null && navigationReplace === false) {
const rootNavigationRef2 = getRootNavigationRef();
const r163 = coerceGuildsRoute(rootNavigationRef2 == null ? void 0 : rootNavigationRef2.getCurrentRoute());
if ((r163 == null ? void 0 : r163.params?.channelId) === channelId) {
navigateToRootTab({
screen: "guilds",
guildId,
channelId,
resetRoot: navigationReplace
});
break L39;
}
navigateToChannel({
channelId,
guildId,
messageId,
replaceChannelAndFixRoot: navigationReplace
});
break L39;
}
navigateToRootTab({
screen: "guilds",
guildId,
channelId,
resetRoot: navigationReplace
});
} else if (channelId != null) {
if (navigationReplace === true && openChannel) {
navigateToChannel({
channelId,
guildId,
messageId,
replaceChannelAndFixRoot: navigationReplace,
openChannel: true
});
break L39;
}
if (navigationReplace !== false) {
navigateToRootTab({
screen: "guilds",
guildId,
channelId,
resetRoot: navigationReplace
});
}
if (channelId != null && navigationReplace !== true) {
navigateToChannel({
channelId,
guildId,
messageId,
replaceChannelAndFixRoot: void 0
});
}
} else {
navigateToRootTab({
screen: "guilds",
guildId,
channelId,
resetRoot: navigationReplace
});
}
}
return true;
}
}
if (pathname.startsWith("/member-verification/")) {
const r109 = matchPath(pathname, {
path: Routes.GUILD_MEMBER_VERIFICATION(RouteParam.guildId())
});
if (r109 != null) {
navigateToMemberVerification(r109.params.guildId, r109.params.inviteCode);
}
return true;
}
L12: {
if (!pathname.startsWith(Routes.LOGIN) && !pathname.startsWith(Routes.REGISTER)) {
r89 = !!pathname.startsWith(Routes.ACCOUNT_STANDING);
if (!r89) {
break L12;
}
rootNavigationRef.navigate({
name: "account-standing",
params: void 0
});
r89 = true;
} else {
resetToAuthRoute();
r89 = true;
}
}
return r89;
}
return true;
}