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,621 @@
// Metro module 16047 (f16048).
import _slicedToArray from "../../../_bundle/_slicedToArray";
import "../../../i18n/native/index";
import "../../../lib/superagentPatch";
import { NativeModules, Linking, LogBox, NativeEventEmitter, AppState } from "react-native";
import "../../debug/logThirdPartyImportsDone";
import { subscribeToIntlLoadingSuccess } from "../../../intl/IntlLoaderStore";
import SelectedChannelStore from "../../../stores/SelectedChannelStore";
import AppStateStore from "../../../stores/native/AppStateStore";
import "../../../stores/AnalyticsTrackingStore";
import "../ManagerRegistry.native";
import { AnalyticEvents, AppStates, Platforms, STORAGE_SECURE_KEYS, TOKEN_KEY, FIRST_RUN_DATE_KEY } from "../../../Constants";
import TTITracker from "../../tti_analytics/TTITracker";
import Logger from "../../debug/Logger";
import { DeeplinkSource } from "../../deep_link/DeepLinkTypes";
import timeRequire from "../../../_bundle/timeRequire";
import * as _handleIncomingURL from "../../links/native/handleIncomingURL";
import BundleUpdater from "../../../lib/native/BundleUpdater";
import Module589 from "../../../_bundle/Module589";
import { batchUpdates } from "../../../_bundle/Module705";
import { TelemetryRingLifecycle } from "../../telemetry_ring/native/index";
import { installWebsocketTelemetryHook } from "../../../lib/websocketTelemetryHook.android";
import ZoomedInTelemetry from "../../telemetry_ring/native/channels/ZoomedInTelemetry";
import { isAndroid } from "../../../utils/PlatformUtils";
import Module10 from "../../../_bundle/Module10";
import BundleUpdaterActionCreators from "../../../actions/native/BundleUpdaterActionCreators";
import Module10610 from "../../../_bundle/Module10610";
import Dispatcher from "../../../Dispatcher";
import * as _handleAppStateChanged from "../../core/native/handleAppStateChanged";
import { isBridgeless } from "../../../utils/native/FabricUtils";
import * as _TTIAnalyticsUtils from "../../tti_analytics/native/TTIAnalyticsUtils";
import SentryUtils_native from "../../../utils/SentryUtils.native";
import * as _receiveNotification from "../../push_notifications/native/receiveNotification";
import * as _LocalPushNotificationActionCreators from "../../local_push_notification/native/LocalPushNotificationActionCreators";
import PushNotification from "../../../lib/pushnotification/PushNotification";
import * as _Module595 from "../../../_bundle/Module595";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import Module502 from "../../../_bundle/Module502";
import DatabaseManager from "../../app_database/system/DatabaseManager";
import { Future } from "../../../_bundle/Module5700";
import { preloadAllIntlMessageFiles } from "../../../intl/preloader";
import { waitForAllDefaultIntlMessagesLoaded } from "../../../_bundle/Module1274";
import "../../../_bundle/asyncRequire";
import { unlockOrientation, lockOrientationForiOS } from "../../device/native/DeviceOrientation";
import { isTTITest } from "../../tti_analytics/isTTITest";
import * as _Module5958 from "../../../_bundle/Module5958";
import * as _DispatcherBridge from "../../libdiscore/DispatcherBridge";
import libDiscoreSmokeTest from "../../libdiscore/libDiscoreSmokeTest";
import { setupLibdiscoreTimersMonitor } from "../../libdiscore/timerUtils";
import { installRNGHMountReactionsBridge } from "../../gesture_handlers/native/RNGHMountReactionsBridge.native";
import MessageManager from "../../messages/MessageManager";
import { INITIAL_MESSAGE_FETCH_KEY } from "../../local_message_caching/MessageCacheStats";
import * as _setSecondaryToken from "../../../_bundle/setSecondaryToken";
import { getToken } from "../../../_bundle/setSecondaryToken";
import * as _awaitExperiments from "../awaitExperiments";
import * as _Module5273 from "../../../_bundle/Module5273";
import { initSessionHeartbeatScheduler } from "../../analytics_sessions/SessionHeartbeatScheduler";
import * as _CacheStore2 from "../../cache/CacheStore";
function $mk98606($env) {
return () => _handleIncomingURL;
}
function $mk117153($env) {
return () => _Module595.Storage.parse($env[0]);
}
function $mk117154($env) {
return () => (0, $env[1])();
}
function $mk117157($env) {
return function trackFirstLaunched() {
return $env[27].apply(this, arguments);
};
}
function $mk117158($env) {
return () => {
_DispatcherBridge;
};
}
function $mk117159($env) {
return () => {
Module589.initialize();
c11509_20.verbose("Flux has initialized");
};
}
function $mk117160($env) {
return (a0) => {
const r2 = $env;
r2[25] = a0.url;
(0, timeRequire("handleURL", $mk98606(r2)).default)(a0, true);
};
}
function $mk117161($env) {
return () => _receiveNotification;
}
function $mk117162($env) {
return (a0) => {
let env31787 = {
$parent: $env
};
env31787[0] = a0;
import("../../cache/CacheStore").then(({ default: default2 }) => {
const r6 = env31787.$parent;
return default2.loadCacheAsync((0, r6[4])((0, r6[0])(r6[3][55]).computeInitialNavigationState(), 1)[0], () => {
const r1 = env31787.$parent;
const r3 = r1[0];
const r2 = r1[3];
const default2 = r3(r2[56]).default;
const default3 = r3(r2[57]).default;
const isMobileVisualRefreshEnabled = r3(r2[58]).isMobileVisualRefreshEnabled;
r3(r2[59]).updateSaturation(default3.saturation);
r3(r2[60]).updateVisualRefresh(isMobileVisualRefreshEnabled("NativeAppStartup"));
r3(r2[61]).updateTheme(default2.theme);
(0, env31787[0])();
});
});
};
}
function $mk117163($env) {
return () => {
c11509_32.resolve();
};
}
function $mk117164($env) {
return () => {
PushNotification.setApplicationIconBadgeNumber($env[18].getTotalMentionCount());
};
}
function $mk117165($env) {
return (a0) => {
a0.default.loadCacheAsync({
page: "other"
}, $mk118519($env));
};
}
function $mk118519($env) {
return () => {
c11509_32.resolve();
};
}
let getInitialURLs, sharedInit, loadStorage, loadKvStorage, initializeIntl, initializeTokenStorage, c11509_20, c11509_32, c11509_33, c11509_37;
let $mk112504 = function() {
return () => _receiveNotification;
};
let env11509 = {};
const linkFromAppsFlyer = function linkFromAppsFlyer(a0) {
let r13;
try {
r13 = new URL(a0).searchParams.get("fromAppsFlyer");
} catch ($e) {
c11509_20.error("Failed to parse URL in linkFromAppsFlyer", {
url: a0,
error: $e
});
return false;
}
return r13 === "true";
};
getInitialURLs = async function getInitialURLs() {
let c30946_1, c30946_2, c30946_3;
c30946_1 = void 0;
c30946_2 = void 0;
c30946_3 = void 0;
let c30946_0 = [];
const initialURL = await NativeModules.DeepLinkManager.getInitialURL();
L14: {
c30946_1 = initialURL;
if (c30946_1 != null && c30946_1.url != null) {
if ((0, linkFromAppsFlyer)(c30946_1.url)) {
c30946_2 = c30946_1.isDeferred ? DeeplinkSource.AppsFlyerDeferred : DeeplinkSource.AppsFlyer;
c30946_0.push({
url: c30946_1.url,
source: c30946_2
});
break L14;
}
c30946_0.push({
url: c30946_1.url,
source: DeeplinkSource.OS
});
} else {
c30946_3 = await Linking.getInitialURL();
if (c30946_3 != null) {
c30946_0.push({
url: c30946_3,
source: DeeplinkSource.ReactNativeLinking
});
}
}
}
return c30946_0;
};
sharedInit = function sharedInit() {
let c22761_0, c22761_1, c22761_2, handleLocalNotification2;
const handleNotification2 = function handleNotification(a0) {
if (c22761_0) {
(0, timeRequire("receiveNotification", $mk112504()).default)(a0, false);
TTITracker.extraProperties.tapped_notification = true;
} else {
c22761_1.push(a0);
}
};
handleLocalNotification2 = function handleLocalNotification(a0) {
if (c22761_0) {
(0, timeRequire("LocalPushNotificationActionCreators", () => _LocalPushNotificationActionCreators).receiveLocalNotification)(a0);
} else {
c22761_2.push(a0);
}
};
BundleUpdater.setupOTAAssetFallback();
Module589.Emitter.injectBatchEmitChanges(batchUpdates);
TelemetryRingLifecycle.initialize();
installWebsocketTelemetryHook((a0) => {
ZoomedInTelemetry.append(AnalyticEvents.WEBSOCKET_MESSAGE_RECEIVED, a0);
});
Linking.addEventListener("url", ({ url }) => {
if (!(isAndroid() && env11509[25] === url)) {
env11509[25] = url;
c11509_37.then(() => {
const r3 = env11509;
c11509_20.log(`Handling URL: ${url}`);
Module10.mark("❗", `Handle URL ${url}`);
const r25 = {
url,
source: linkFromAppsFlyer(url) ? DeeplinkSource.AppsFlyer : DeeplinkSource.OS
};
(0, timeRequire("handleURL", $mk98606(r3)).default)(r25, false);
});
}
});
LogBox.ignoreLogs(["Non-serializable values were found in the navigation state", "Overriding previous layout animation with new one before the first began", "Check the render method of `SceneView`", "Open debugger to view warnings."]);
BundleUpdater.getInitialBundleDownloaded().then((result) => {
if (result != null && result.versionRequired != null) {
c11509_20.verbose(`Get initial downloaded bundle ${result.versionRequired}`);
BundleUpdaterActionCreators.prepareUpdate(result.versionRequired);
}
});
BundleUpdater.addEventListener("downloaded", ({ versionRequired }) => {
c11509_20.verbose(`Bundle Event: bundle downloaded for ${versionRequired}`);
BundleUpdaterActionCreators.prepareUpdate(versionRequired);
});
BundleUpdater.getInitialOtaUpdateChecked().then(({ metrics }) => {
c11509_20.verbose("Initial OTA update check metrics", metrics);
for (const item of metrics) {
BundleUpdater.emitOtaMetric(item);
}
});
BundleUpdater.addEventListener("otaUpdateChecked", ({ metrics }) => {
c11509_20.verbose("OTA update check metrics", metrics);
for (const item of metrics) {
BundleUpdater.emitOtaMetric(item);
}
});
new NativeEventEmitter(Module10610).addListener("appWillEnterForeground", () => {
Dispatcher.dispatch({
type: "APP_STATE_UPDATE_WILL_BECOME_ACTIVE"
});
});
if (AppStateStore.getState() !== AppState.currentState) {
(0, timeRequire("handleAppStateChange", () => _handleAppStateChanged).default)(AppState.currentState);
} else if (isBridgeless && !isAndroid() && !env11509[21] && AppState.currentState === AppStates.ACTIVE) {
env11509[21] = true;
(0, timeRequire("trackAppOpened", () => _TTIAnalyticsUtils).trackAppOpened)("launcher");
}
AppState.addEventListener("change", (a0) => {
TTITracker.imports.appStateChangeStart.record();
Module10.resumeTracing();
SentryUtils_native.addBreadcrumb({
message: `App state changed to ${a0}`,
category: "appState"
});
(0, timeRequire("handleAppStateChange", () => _handleAppStateChanged).default)(a0);
TTITracker.imports.appStateChangeEnd.record();
});
if (NativeModules.Hosts != null) {
NativeModules.Hosts.setHosts(`${location.protocol}${window.GLOBAL_ENV.API_ENDPOINT}`, `${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}`);
}
c22761_0 = false;
c22761_1 = [];
c22761_2 = [];
PushNotification.addNotificationEventListener("notification", (a0) => {
const state = AppStateStore.getState();
c11509_20.log(`Push notification received, the app state is ${state}`);
if (state !== AppStates.ACTIVE) {
if (c22761_0) {
(0, timeRequire("receiveNotification", $mk112504()).default)(a0, false);
TTITracker.extraProperties.tapped_notification = true;
} else {
c22761_1.push(a0);
}
}
});
PushNotification.addNotificationEventListener("localNotification", handleLocalNotification2);
return {
onStorageInitialize: () => {
c22761_0 = true;
c22761_1.forEach(handleNotification2);
c22761_2.forEach(handleLocalNotification2);
c22761_1.length = 0;
c22761_2.length = 0;
}
};
};
env11509[27] = function _trackFirstLaunched() {
const r8 = async () => {
let c28213_0, APP_FIRST_LAUNCHED, c28213_2, c28213_3, track;
L18: {
c28213_2 = env11509;
if (_Module595.Storage.get(AnalyticEvents.APP_FIRST_LAUNCHED, true)) {
c28213_3 = AnalyticsUtils;
track = AnalyticsUtils.track;
APP_FIRST_LAUNCHED = AnalyticEvents.APP_FIRST_LAUNCHED;
const r38 = {};
c28213_0 = r38;
r38.platform = isAndroid() ? Platforms.ANDROID : Platforms.IOS;
const InstallReferrer = NativeModules.InstallReferrer;
const referrer = await (InstallReferrer == null ? void 0 : InstallReferrer.get());
const r67 = c28213_0;
const r70 = c28213_3;
r67.referrer = referrer;
track.call(r70, APP_FIRST_LAUNCHED, r67);
_Module595.Storage.set(AnalyticEvents.APP_FIRST_LAUNCHED, false);
break L18;
}
return void 0;
}
};
env11509[27] = r8;
return r8.apply(this, arguments);
};
loadStorage = async function loadStorage() {
let c28214_0, c28214_1, c28214_2;
let c28214_3 = 0;
const r12 = env11509;
L10: {
try {
let env30947;
c28214_1 = r12;
const r27 = env30947 = {
$parent: r12
};
c28214_0 = r27;
env30947[0] = void 0;
c28214_3 = 1;
TTITracker.loadStorage.recordStart();
const r46 = await _Module595.Storage.refresh([], STORAGE_SECURE_KEYS);
const r57 = c28214_0;
env30947[0] = r46;
TTITracker.loadStorage.recordEnd();
TTITracker.parseStorage.measureAsync($mk117153(r57));
c28214_3 = 0;
} catch ($e) {
const r25 = $e;
let r8 = r25;
c28214_2 = r25;
if (c28214_3 !== 0) {
while (true) {
try {
const r82 = c28214_2;
c28214_3 = 0;
env30947[1] = r82;
c11509_20.error("Unable to load Storage", env30947[1]);
break L10;
} catch (r78) {
r8 = r78;
c28214_2 = r78;
if (c28214_3 === 0) {
break;
}
}
}
}
throw r8;
}
}
};
loadKvStorage = function loadKvStorage() {
try {
DatabaseManager.initialize();
} catch (r9) {
c11509_20.warn("DatabaseManager.initialize errored.", r9);
SentryUtils_native.captureException(r9);
}
return Promise.resolve();
};
initializeIntl = async function initializeIntl(c28215_0) {
let env30948;
let c28215_2 = env11509;
const r33 = env30948 = {};
let c28215_1 = r33;
env30948[0] = void 0;
env30948[0] = c28215_0.log;
env30948[1] = void 0;
await void 0;
await preloadAllIntlMessageFiles();
await waitForAllDefaultIntlMessagesLoaded();
if (env30948[0]) {
Module10.markAndLog(c11509_20, "🌎", "i18n loaded");
}
env30948[1] = (await import("../../../i18n/native/i18nMessagesProvider")).default;
await (0, env30948[1])();
(0, subscribeToIntlLoadingSuccess)($mk117154(c28215_1));
};
initializeTokenStorage = function initializeTokenStorage() {
let r15;
if (_Module595.Storage.get(TOKEN_KEY) == null) {
const r11 = isAndroid() ? Module502.getConstants().token : NativeModules.DCDFastConnectManager.token;
if (r11 != null) {
c11509_20.log("Applying token storage fix.");
_Module595.Storage.set(TOKEN_KEY, r11);
r15 = c11509_20;
} else {
c11509_20.log("Cannot apply token storage fix as token not in NSUserDefaults.");
r15 = c11509_20;
}
} else {
r15 = c11509_20;
r15.verbose("No need to apply token storage fix as token already exists.");
}
_setSecondaryToken.init();
const tokenManagerHasToken = getToken() != null;
r15.verbose("Token manager has initialized", {
storageHasToken: _Module595.Storage.get(TOKEN_KEY) != null,
tokenManagerHasToken
});
(0, env11509[31])();
};
TTITracker.loadImports.recordEnd();
c11509_20 = new Logger("index.native.tsx");
env11509[21] = false;
env11509[25] = null;
c11509_32 = new Future();
c11509_33 = {
None: 0,
0: "None",
HeadlessRan: 1,
1: "HeadlessRan",
Full: 2,
2: "Full"
};
env11509[34] = c11509_33.None;
c11509_37 = new Promise((resolve) => {
env11509[31] = resolve;
});
TTITracker.loadIndex.recordEnd();
export { c11509_32 as applicationReady };
export async function init() {
let c28216_0, c28216_1;
L52: {
let env30949;
const r13 = env11509;
c28216_1 = r13;
const r10 = env30949 = {
$parent: r13
};
c28216_0 = r10;
env30949[0] = void 0;
env30949[1] = void 0;
env30949[2] = void 0;
env30949[3] = void 0;
env30949[4] = void 0;
env30949[5] = void 0;
env30949[6] = void 0;
env30949[7] = void 0;
env30949[8] = void 0;
env30949[9] = void 0;
env30949[10] = void 0;
env30949[11] = void 0;
env30949[12] = void 0;
env30949[13] = void 0;
env30949[14] = void 0;
env30949[15] = void 0;
env30949[16] = void 0;
env30949[17] = void 0;
env30949[18] = void 0;
env30949[19] = void 0;
const r14 = env11509[34];
if (r14 !== c11509_33.Full) {
const r38 = env11509[34] === c11509_33.HeadlessRan;
env30949[0] = r38;
env11509[34] = c11509_33.Full;
env30949[1] = void 0;
if (!r38) {
env30949[1] = sharedInit().onStorageInitialize;
}
if (isAndroid()) {
unlockOrientation({
unlockAfterRotatingToPreviousLock: false
});
} else {
lockOrientationForiOS();
}
TTITracker.didBackgroundApp = AppState.currentState === AppStates.BACKGROUND;
TTITracker.imports.loadStorageStart.record();
env30949[2] = await Promise.all([getInitialURLs(), PushNotification.getInitialNotification().catch(() => null), loadStorage(), loadKvStorage(), import("../../react_asset/native/reactAssetProvider").then((result) => (0, result.default)())]);
env30949[3] = (0, _slicedToArray)(env30949[2], 2);
env30949[4] = env30949[3][0];
env30949[5] = env30949[3][1];
TTITracker.imports.loadStorageEnd.record();
if (isAndroid()) {
if (isTTITest) {
env30949[6] = _Module5958.default;
await env30949[6].yieldConfig();
}
}
env30949[7] = env30949[0] ? Promise.resolve() : (0, initializeIntl)({
log: true
});
Module10.markAndLog(c11509_20, "🏃", "The initial promise has resolved");
if (env30949[4] != null && env30949[4].length > 0) {
c11509_20.log("initialURLs", env30949[4]);
}
if (env30949[5] != null) {
c11509_20.log("initialNotification", env30949[5]);
}
if (_Module595.Storage.get(FIRST_RUN_DATE_KEY) == null) {
_Module595.Storage.set(FIRST_RUN_DATE_KEY, Date.now());
}
$mk117157(env11509)();
if (!env30949[0]) {
(0, initializeTokenStorage)();
const r264 = env30949[1];
if (r264 != null) {
r264();
}
}
timeRequire("DispatcherBridge", $mk117158(env11509));
if (env30949[0]) {
Module10.markAndLog(c11509_20, "🏃", "Flux already initialized.");
} else {
Module10.time("🏃", "Flux.initialize()", $mk117159(env11509));
}
libDiscoreSmokeTest();
setupLibdiscoreTimersMonitor();
installRNGHMountReactionsBridge();
env30949[4].forEach($mk117160(env11509));
env30949[8] = false;
if (env30949[5] != null) {
env30949[9] = timeRequire("receiveNotification", $mk117161(env11509)).default;
TTITracker.extraProperties.tapped_notification = true;
env30949[8] = (0, env30949[9])(env30949[5], true);
}
if (!env30949[8]) {
env30949[10] = SelectedChannelStore.getChannelId();
if (env30949[10] != null) {
MessageManager.fetchMessages({
channelId: env30949[10],
isPreload: true,
skipLocalFetch: true,
fetchKey: INITIAL_MESSAGE_FETCH_KEY
});
}
}
TTITracker.imports.loadMiniCacheStart.record();
env30949[11] = new Promise($mk117162(env11509));
env30949[12] = null;
if (getToken() != null) {
env30949[12] = Promise.resolve();
} else {
env30949[13] = _awaitExperiments;
env30949[13].beginLoadedExperimentsTimeout();
env30949[12] = env30949[13].getPromise();
}
Promise.all([env30949[11], env30949[12]]).then($mk117163(env11509));
const r458 = await Promise.all([import("../../network/NetStats.android"), import("../../notifications/native/NotificationTokenManager"), import("../../rpc/native/server/NativeRPCServerManager"), import("../../../stores/GuildReadStateStore"), import("../../debug/native/AppCrashedFatalReport.android"), env30949[7]]);
const r466 = c28216_0;
env30949[14] = r458;
env30949[15] = (0, _slicedToArray)(env30949[14], 5);
env30949[15][0];
env30949[16] = env30949[15][1].default;
env30949[17] = env30949[15][2].default;
env30949[18] = env30949[15][3].default;
env30949[19] = env30949[15][4];
env30949[16].registerNotificationCategories();
env30949[16].registerListener();
env30949[17].loadServer();
env30949[18].addChangeListener($mk117164(r466));
if (!env30949[0]) {
env30949[19].init();
}
_Module5273;
initSessionHeartbeatScheduler();
break L52;
}
SentryUtils_native.addBreadcrumb({
message: "Init called when already initialized"
});
return void 0;
}
}
export async function initHeadlessTask() {
let c28217_0, c28217_1;
L15: {
let env30950;
const r12 = env11509;
c28217_1 = r12;
const r10 = env30950 = {
$parent: r12
};
c28217_0 = r10;
env30950[0] = void 0;
env30950[1] = void 0;
const r13 = env11509[34];
if (r13 === c11509_33.None) {
env11509[34] = c11509_33.HeadlessRan;
env30950[0] = sharedInit().onStorageInitialize;
await Promise.all([loadStorage(), loadKvStorage(), initializeIntl({
log: false
})]);
(0, initializeTokenStorage)();
(0, env30950[0])();
_CacheStore2;
_DispatcherBridge;
Module589.initialize();
import("../../cache/CacheStore").then($mk117165(env11509));
env30950[1] = await Promise.all([import("../../debug/native/AppCrashedFatalReport.android")]);
(0, _slicedToArray)(env30950[1], 1)[0].init();
libDiscoreSmokeTest();
break L15;
}
return void 0;
}
}
@@ -0,0 +1,224 @@
// Metro module 16765 (f16766).
import { AppState } from "react-native";
import AuthenticationStore from "../../../stores/AuthenticationStore";
import { applicationReady, initHeadlessTask } from "./NativeAppStartup";
import { AnalyticEvents } from "../../../Constants";
import Logger from "../../debug/Logger";
import SentryUtils_native from "../../../utils/SentryUtils.native";
import { recordStartHeadlessTask } from "../../gateway/RequestGatewaySocket";
import { closeFastConnectSocket } from "../../gateway/native/fast_connect";
import TTITracker from "../../tti_analytics/TTITracker";
import { setIsPaused } from "../../gateway/PauseGatewaySocket";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import { AnalyticsActionHandlers } from "../../../_bundle/Module503";
import { timeoutPromise } from "../../../_bundle/Timeout";
export default async function executeHeadlessTask(name, c28527_1, c28527_2) {
let value, value2, value3, c28527_6, c28527_10;
let c28527_9 = 0;
let c31120_0, c31120_1, c31120_2, c31120_3, c31120_4, c31120_5, c31120_6, c31120_7, c31120_8;
const r31 = "Pausing socket in headless task because app state is not active";
L35: {
try {
c31120_0 = name;
c31120_1 = c28527_1;
c31120_2 = c28527_2;
c31120_3 = void 0;
c31120_4 = void 0;
c31120_5 = void 0;
c31120_6 = void 0;
c31120_7 = void 0;
const logger = new Logger(`Task ${name}`);
c31120_3 = logger;
c31120_4 = Date.now();
SentryUtils_native.addBreadcrumb({
message: "Executing headless task.",
data: {
name
}
});
recordStartHeadlessTask();
closeFastConnectSocket();
c31120_5 = false;
c28527_9 = 1;
if (!TTITracker.wasEverActive) {
TTITracker.extraProperties.headless_task_ran = true;
}
if (AppState.currentState !== "active") {
logger.log(r31);
setIsPaused(true);
}
AnalyticsUtils.track(AnalyticEvents.HEADLESS_TASK_INVOKED, {
client_app_state: AppState.currentState,
name
});
value3 = await initHeadlessTask();
c31120_3.log("initHeadlessTask completed");
value2 = await applicationReady.promise;
c31120_3.log("Flux Initialized");
if (AuthenticationStore.isAuthenticated()) {
AnalyticsActionHandlers.handleConnectionOpen({
analyticsToken: AuthenticationStore.getAnalyticsToken(),
user: {
id: AuthenticationStore.getId()
}
});
c31120_3.log("Analytics Initialized");
} else {
c31120_3.log("Analytics Init skipped; not authenticated");
}
value = await (0, c31120_1)()(c31120_2);
c31120_5 = true;
c31120_3.log("Task completed successfully");
c28527_9 = 0;
c31120_6 = Date.now() - c31120_4;
SentryUtils_native.addBreadcrumb({
message: "Finished headless task.",
data: {
name: c31120_0,
success: c31120_5,
duration: c31120_6 + "ms"
}
});
c31120_3.log("Unpausing socket");
setIsPaused(false);
c31120_7 = AnalyticsUtils.track(AnalyticEvents.HEADLESS_TASK_COMPLETED, {
client_app_state: AppState.currentState,
name: c31120_0,
success: c31120_5,
duration_ms: c31120_6
}, {
flush: true
});
c28527_9 = 6;
await Promise.race([c31120_7, timeoutPromise(1500)]);
c28527_9 = 0;
} catch ($e) {
const r63 = $e;
let r8 = r63;
c28527_10 = r63;
let r64 = c28527_9;
if (r64 !== 0) {
while (true) {
if (r64 === 1) {
try {
c28527_6 = c28527_10;
c28527_9 = 0;
c31120_6 = Date.now() - c31120_4;
SentryUtils_native.addBreadcrumb({
message: "Finished headless task.",
data: {
name: c31120_0,
success: c31120_5,
duration: c31120_6 + "ms"
}
});
c31120_3.log("Unpausing socket");
setIsPaused(false);
c31120_7 = AnalyticsUtils.track(AnalyticEvents.HEADLESS_TASK_COMPLETED, {
client_app_state: AppState.currentState,
name: c31120_0,
success: c31120_5,
duration_ms: c31120_6
}, {
flush: true
});
c28527_9 = 2;
await Promise.race([c31120_7, timeoutPromise(1500)]);
c28527_9 = 0;
throw c28527_6;
} catch (r457) {
r8 = r457;
c28527_10 = r457;
r64 = c28527_9;
if (r64 === 0) {
break;
}
}
} else if (r64 === 2) {
try {
const r448 = c28527_10;
c28527_9 = 0;
c31120_8 = r448;
c31120_3.warn("Failed to submit analytics", c31120_8);
throw c28527_6;
} catch (r446) {
r8 = r446;
c28527_10 = r446;
r64 = c28527_9;
if (r64 === 0) {
break;
}
}
} else {
if (r64 === 3) {
try {
const r436 = c28527_10;
c28527_9 = 0;
c31120_8 = r436;
c31120_3.warn("Failed to submit analytics", c31120_8);
} catch (r434) {
r8 = r434;
c28527_10 = r434;
r64 = c28527_9;
if (r64 === 0) {
break;
}
continue;
}
return value3;
}
if (r64 === 4) {
try {
const r424 = c28527_10;
c28527_9 = 0;
c31120_8 = r424;
c31120_3.warn("Failed to submit analytics", c31120_8);
} catch (r422) {
r8 = r422;
c28527_10 = r422;
r64 = c28527_9;
if (r64 === 0) {
break;
}
continue;
}
return value2;
}
if (r64 === 5) {
try {
const r412 = c28527_10;
c28527_9 = 0;
c31120_8 = r412;
c31120_3.warn("Failed to submit analytics", c31120_8);
} catch (r410) {
r8 = r410;
c28527_10 = r410;
r64 = c28527_9;
if (r64 === 0) {
break;
}
continue;
}
return value;
}
try {
const r401 = c28527_10;
c28527_9 = 0;
c31120_8 = r401;
c31120_3.warn("Failed to submit analytics", c31120_8);
break L35;
} catch (r399) {
r8 = r399;
c28527_10 = r399;
r64 = c28527_9;
if (r64 === 0) {
break;
}
}
}
}
}
throw r8;
}
}
};
@@ -0,0 +1,26 @@
// Metro module 16046 (f16047).
import { applicationReady, init } from "./NativeAppStartup";
import Logger from "../../debug/Logger";
import { setIsPaused } from "../../gateway/PauseGatewaySocket";
import { withRequest, startBridgeTo } from "../../gateway/RequestGatewaySocket";
import { identifyWebSocket } from "../../gateway/native/fast_connect";
import TTITracker from "../../tti_analytics/TTITracker";
import Module10 from "../../../_bundle/Module10";
import Module589 from "../../../_bundle/Module589";
function $mk117152($env) {
return () => Module589.Emitter.batched(c22760_1);
}
export default function executeRunnable(a0, c22760_1) {
new Logger(a0).log(`Loading the ${a0} Discord runnable`);
setIsPaused(false);
return withRequest(`executeRunnable:${a0}`, async () => {
const r29 = void 0;
let c28210_1 = r29;
let c28210_0 = r29;
identifyWebSocket();
await TTITracker.init.measureAsync(init);
await applicationReady.promise;
startBridgeTo(`AppContainer:${a0.toLowerCase()}`);
return Module10.time("🏃", "Run", $mk117152(c28210_0));
});
};