This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,37 @@
// Metro module 13505 (f13506).
import { BackHandler } from "react-native";
import { hideContextMenu } from "../../../design/components/ContextMenu/native/ContextMenuState.native";
import { getKeyboardType } from "../../keyboard/native/useKeyboardType";
import { KeyboardTypes } from "../../keyboard/native/KeyboardTypes";
import { setKeyboardType } from "../../keyboard/native/KeyboardUIStore.native";
import LifecycleManager from "../../../lib/LifecycleManager";
import { isAndroid } from "../../../utils/PlatformUtils";
const handleBackPress = function handleBackPress() {
hideContextMenu();
let r0 = getKeyboardType() !== KeyboardTypes.SYSTEM;
if (r0) {
setKeyboardType({
type: KeyboardTypes.SYSTEM
});
r0 = true;
}
return !!r0;
};
class BackPressManager extends LifecycleManager {
_initialize() {
if (isAndroid()) {
this._initializeGlobalBackPressListener();
}
}
_initializeGlobalBackPressListener() {
this._backPressEventSubscription = BackHandler.addEventListener("hardwareBackPress", handleBackPress);
}
_terminate() {
const _backPressEventSubscription = this._backPressEventSubscription;
if (_backPressEventSubscription != null) {
_backPressEventSubscription.remove();
}
}
}
const backPressManager = new BackPressManager();
export default backPressManager;
@@ -0,0 +1,321 @@
// Metro module 10868 (f10869).
import { setVoiceChatDrawerState } from "../../video_calls/native/ChannelCallStore";
import { isGuildSelectableChannelType } from "../../../records/ChannelRecord";
import ChannelStore from "../../../stores/ChannelStore";
import DefaultRouteStore from "../../../stores/DefaultRouteStore";
import GuildChannelStore from "../../../stores/GuildChannelStore";
import SelectedChannelStore from "../../../stores/SelectedChannelStore";
import { ChannelTypes, ME, Routes } from "../../../Constants";
import { VoiceChatDrawerState } from "../../video_calls/native/ChannelCallConstants";
import Logger from "../../debug/Logger";
import { isValidGuildId, isValidChannelId, RouteParam } from "../RouteUtils";
import { matchPath } from "../../../_bundle/Module10869";
import SelectedChannelActionCreators from "../../../actions/SelectedChannelActionCreators";
import { transitionTo, transitionToGuild } from "../router_utils";
import { saveLastRoute, saveLastNonVoiceRoute } from "../../../actions/DefaultRouteActionCreators";
import ModalActionCreators from "../../../actions/ModalActionCreators";
import { getVoiceChannelKey, openGuildVoiceModal } from "../../../utils/native/PrivateChannelCallUtils";
import GuildActionCreators from "../../../actions/GuildActionCreators";
import { isVoicePanelEnabled } from "../../voice_panel/VoicePanelUtils.native";
import { isModalOpen } from "../../main_tabs_v2/helpers/NavigationRouteUtils.native";
import Dispatcher from "../../../Dispatcher";
import ChannelRTCActionCreators from "../../../actions/ChannelRTCActionCreators";
import { JumpType } from "../../../flow/Client";
import RouteManager from "../RouteManager";
let _excluded, c7306_15, c7306_16, path, saveLastRouteListener, saveLastNonVoiceRouteListener, updateSelectedChannelListener, extractParams, logRouteChange;
const voiceRouteRewriter = function voiceRouteRewriter(a0) {
let r30, state;
L9: {
state = a0.state;
const r21 = extractParams({
match: matchPath(a0.pathname, {
path,
strict: false,
exact: false
}),
location: a0
});
const { channelId, guildId, ...rest } = r21;
const channel2 = ChannelStore.getChannel(channelId);
const r2 = channelId == null;
r30 = null;
if (!r2) {
const r31 = guildId == null;
r30 = null;
if (!r31) {
if (channel2?.type !== ChannelTypes.GUILD_VOICE) {
const type = channel2?.type;
const GUILD_STAGE_VOICE = ChannelTypes.GUILD_STAGE_VOICE;
r30 = null;
if (type !== GUILD_STAGE_VOICE) {
break L9;
}
}
r30 = {
...rest,
channelId,
guildId
};
}
}
}
if (r30 != null) {
if (c7306_15 != null) {
c7306_15.log(`voiceRouteRewriter: has voiceChannelParams = ${JSON.stringify(r30)}`);
}
const path2 = `${DefaultRouteStore.lastNonVoiceRoute}${Routes.VOICE_CHAT_CHANNEL_PARTIAL(r30.guildId, r30.channelId, r30.messageId)}`;
const pathname = a0.pathname;
let r65 = null;
if (path2 !== pathname) {
if (c7306_15 != null) {
c7306_15.log(`voiceRouteRewriter: rewriting route: ${a0.pathname} -> ${path2}`);
}
r65 = {
path: path2,
state
};
}
return r65;
}
return null;
};
saveLastRouteListener = function saveLastRouteListener(a0) {
saveLastRoute(a0.pathname);
};
saveLastNonVoiceRouteListener = function saveLastNonVoiceRouteListener(a0) {
const match = matchPath(a0.pathname, {
path,
strict: false,
exact: false
});
const channel2 = ChannelStore.getChannel(match == null ? void 0 : match.params.channelId);
const r23 = channel2?.type !== ChannelTypes.GUILD_VOICE ? channel2?.type !== ChannelTypes.GUILD_STAGE_VOICE ? extractParams({
match,
location: a0
}) : null : null;
if (r23 != null) {
saveLastNonVoiceRoute(Routes.CHANNEL(r23.guildId, r23.channelId));
}
};
updateSelectedChannelListener = function updateSelectedChannelListener(a0) {
const match = matchPath(a0.pathname, {
path,
strict: false,
exact: false
});
let r38 = match?.params;
if (r38 == null) {
r38 = {};
}
const { voiceChannelId: voiceChannelId2, voiceGuildId: voiceGuildId2, voiceMessageId: voiceMessageId2 } = r38;
const r42 = {
...extractParams({
match,
location: a0
}),
voiceChannelId: voiceChannelId2,
voiceGuildId: voiceGuildId2,
voiceMessageId: voiceMessageId2
};
const { guildId, channelId, messageId, jumpType, voiceChannelId, voiceGuildId, voiceMessageId, skipMessageFetch } = r42;
if (voiceChannelId == null && voiceGuildId == null) {
if (c7306_15 != null) {
c7306_15.verbose(`UpdateSelectedChannelListener -> no voice route present in ${JSON.stringify(a0)} ${JSON.stringify({
guildId,
channelId,
messageId,
jumpType,
voiceChannelId,
voiceGuildId,
voiceMessageId
})} `);
}
const channel2 = ChannelStore.getChannel(SelectedChannelStore.getLastSelectedChannelId());
if ((channel2 == null ? void 0 : channel2.isGuildVoice()) || (channel2 == null ? void 0 : channel2.isGuildStageVoice())) {
ModalActionCreators.popWithKey(getVoiceChannelKey(channel2.id));
}
GuildActionCreators.selectGuild(guildId);
SelectedChannelActionCreators.selectChannel({
guildId,
channelId,
messageId,
jumpType,
skipMessageFetch
});
return void 0;
}
const channel = ChannelStore.getChannel(voiceChannelId);
const type = channel?.type;
L33: {
if (type !== ChannelTypes.GUILD_VOICE && channel?.type !== ChannelTypes.GUILD_STAGE_VOICE) {
if (c7306_15 == null) {
break L33;
}
c7306_15.log(`UpdateSelectedChannelListener -> !!!VERY BAD!!! channel.id ${channel?.id} (voiceChannelId ${voiceChannelId}) is not a voice channel! and yet RouteUtils thinks it is! ${JSON.stringify(a0)} ${JSON.stringify({
guildId,
channelId,
messageId,
jumpType,
voiceChannelId,
voiceGuildId,
voiceMessageId
})} `);
} else {
if (c7306_15 != null) {
c7306_15.verbose(`UpdateSelectedChannelListener -> voice route present! ${JSON.stringify(a0)} ${JSON.stringify({
guildId,
channelId,
messageId,
jumpType,
voiceChannelId,
voiceGuildId,
voiceMessageId
})} `);
}
if (!isVoicePanelEnabled(channel)) {
GuildActionCreators.selectGuild(voiceGuildId);
SelectedChannelActionCreators.selectChannel({
guildId: voiceGuildId,
channelId: voiceChannelId,
messageId: voiceMessageId,
jumpType
});
}
if (!isModalOpen(getVoiceChannelKey(channel.id))) {
ModalActionCreators.popAboveKey(getVoiceChannelKey(channel.id));
Dispatcher.wait(() => {
openGuildVoiceModal(channel);
});
}
if (channel.isGuildVoice() && voiceMessageId != null || channel.isGuildStageVoice()) {
setVoiceChatDrawerState(channel.id, VoiceChatDrawerState.OPEN);
if (voiceGuildId != null && voiceChannelId != null && voiceMessageId != null) {
ChannelRTCActionCreators.jumpToVoiceChannelMessage(voiceGuildId, voiceChannelId, voiceMessageId, jumpType);
}
}
}
}
};
extractParams = function extractParams({ match, location: location2 }) {
if (match == null) {
return {
guildId: ME,
channelId: null,
messageId: null,
jumpType: JumpType.ANIMATED,
skipMessageFetch: false
};
}
const params = match.params;
let guildId = params.guildId;
const { channelId, messageId } = params;
const jumpType = location2.jumpType === JumpType.INSTANT ? JumpType.INSTANT : JumpType.ANIMATED;
if (!isValidGuildId(guildId)) {
guildId = ME;
}
return {
guildId,
channelId: isValidChannelId(channelId) ? channelId : null,
messageId,
jumpType,
skipMessageFetch: !!location2.skipMessageFetch
};
};
logRouteChange = function logRouteChange(a0) {
c7306_15.log(`Navigated to: ${a0.pathname}`);
};
_excluded = ["channelId", "guildId"];
c7306_15 = new Logger("RouteUtils");
c7306_16 = false;
const r67 = Routes.CHANNEL(RouteParam.guildId(), RouteParam.channelId({
optional: true
}), ":messageId?");
path = [`${r67}${Routes.VOICE_CHAT_CHANNEL_PARTIAL(RouteParam.guildId({
name: "voiceGuildId"
}), RouteParam.channelId({
name: "voiceChannelId"
}), ":voiceMessageId?")}`, r67];
export { r67 as MAIN_DRAWER_ROUTES };
export function extractParamsFromVoiceModalRoute(a0) {
const match = matchPath(a0.pathname, {
path,
strict: false,
exact: false
});
let r16 = match?.params;
if (r16 == null) {
r16 = {};
}
const { voiceChannelId, voiceGuildId, voiceMessageId } = r16;
return {
...extractParams({
match,
location: a0
}),
voiceChannelId,
voiceGuildId,
voiceMessageId
};
}
export function popVoiceRoute(a0) {
let id;
c7306_15.log(`popVoiceRoute: last non-voice route is ${DefaultRouteStore.lastNonVoiceRoute}`);
const channel2 = ChannelStore.getChannel(SelectedChannelStore.getLastSelectedChannelId());
if (channel2?.type != null && isGuildSelectableChannelType(channel2?.type)) {
id = channel2.id;
} else {
id = SelectedChannelStore.getMostRecentSelectedTextChannelId(a0);
if (id == null) {
id = GuildChannelStore.getDefaultChannel(a0)?.id;
}
}
SelectedChannelActionCreators.selectChannel({
guildId: a0,
channelId: id
});
transitionTo(DefaultRouteStore.lastNonVoiceRoute);
}
export function transitionToVoiceRoute(a0, a1) {
let r28 = matchPath(DefaultRouteStore.defaultRoute, {
path,
strict: false,
exact: false
})?.params;
if (r28 == null) {
r28 = {};
}
const voiceChannelId = r28.voiceChannelId;
c7306_15.log(`transitionToVoiceRoute(<${a0}>, <${a1}>), current route ${DefaultRouteStore.defaultRoute} has voiceChannelId ${voiceChannelId}`);
if (voiceChannelId !== a1) {
transitionToGuild(a0, a1);
} else {
c7306_15.log(`transitionToVoiceRoute -> ${voiceChannelId} === ${a1}. staying where we are`);
}
}
export { voiceRouteRewriter };
export { saveLastRouteListener };
export { saveLastNonVoiceRouteListener };
export { updateSelectedChannelListener };
export { extractParams };
export function initializeRouteManagerIfNeeded() {
if (!c7306_16) {
RouteManager.addRouteRewriter(voiceRouteRewriter);
RouteManager.addRouteChangeListener(saveLastRouteListener);
RouteManager.addRouteChangeListener(saveLastNonVoiceRouteListener);
RouteManager.addRouteChangeListener(updateSelectedChannelListener);
RouteManager.addRouteChangeListener(logRouteChange);
RouteManager.initialize();
c7306_16 = true;
}
}
export function cleanupRouteManager() {
if (c7306_16) {
RouteManager.removeRouteRewriter(voiceRouteRewriter);
RouteManager.removeRouteChangeListener(saveLastRouteListener);
RouteManager.removeRouteChangeListener(saveLastNonVoiceRouteListener);
RouteManager.removeRouteChangeListener(updateSelectedChannelListener);
RouteManager.removeRouteChangeListener(logRouteChange);
RouteManager.cleanup();
c7306_16 = false;
}
}
@@ -0,0 +1,29 @@
// Metro module 4597 (f4598).
import { useRef, useLayoutEffect, useEffect } from "react";
import { BackHandler, NativeModules } from "react-native";
import { isIOS } from "../../../utils/PlatformUtils";
const r19 = {
minimize: () => {
NativeModules.MinimizeApp.minimizeApp();
return true;
}
};
export default function useBackPressHandler(a0) {
const current = a0;
let r6 = arguments[1];
if (r6 === void 0) {
r6 = true;
}
let c14340_1 = r6;
const ref = useRef(a0);
useLayoutEffect(() => {
ref.current = current;
});
useEffect(() => {
if (!isIOS() && c14340_1) {
let c25252_0 = BackHandler.addEventListener("hardwareBackPress", () => ref.current());
return () => c25252_0.remove();
}
}, [r6]);
};
export { r19 as BackPressHandler };