Files
discord-decomp/modules/mobile_native_updater/MobileNativeUpdateUtils.tsx
T
2026-11-01 12:12:55 +02:00

74 lines
2.3 KiB
TypeScript

// Metro module 13044 (f13045).
import { UPDATE_CONFIG } from "./MobileNativeUpdateConstants";
import Logger from "../debug/Logger";
import { HTTP } from "../../_bundle/sendRequest";
import * as _Linking from "../../lib/native/Linking";
import { isIOS } from "../../utils/PlatformUtils";
import { WebBrowserType } from "../../ConstantsIOS";
let c9003_4;
const openBuildInstallerUrl = function openBuildInstallerUrl(a0) {
L9: {
try {
const uRL = new URL(a0);
if (uRL.origin !== (UPDATE_CONFIG == null ? void 0 : UPDATE_CONFIG.url.origin)) {
c9003_4.error(`Attempted to follow invalid install URL ${uRL}`);
break L9;
}
const openURLExternally = _Linking.default.openURLExternally;
if (isIOS()) {
const SAFARI = WebBrowserType.SAFARI;
openURLExternally(uRL.toString(), SAFARI);
} else {
openURLExternally(uRL.toString());
}
} catch ($e) {}
return void 0;
}
};
c9003_4 = new Logger("MobileNativeUpdateUtils");
export async function checkForNewerBuild() {
let r106;
let c27405_1;
let c30609_0, c30609_1;
L18: {
L17: {
c27405_1 = void 0;
c30609_0 = void 0;
c30609_1 = void 0;
if (UPDATE_CONFIG === null) {
break L18;
}
c9003_4.info(`Checking ${UPDATE_CONFIG.url} for updates`);
c30609_0 = await HTTP.get({
url: UPDATE_CONFIG.url.toString(),
headers: {
Accept: "application/json"
},
rejectWithError: false
});
if (!c30609_0.ok) {
throw c30609_0;
}
c30609_1 = {
build: c30609_0.body.build,
version: c30609_0.body.version,
buildTimestamp: new Date(c30609_0.body.build_timestamp),
urls: c30609_0.body.urls
};
if (c30609_1.build > UPDATE_CONFIG.currentBuild && c30609_1.version >= UPDATE_CONFIG.currentVersion) {
c9003_4.info(`Update build ${c30609_1.build} is newer than ${UPDATE_CONFIG.currentBuild}`);
r106 = c30609_1;
break L17;
}
c9003_4.info(`Update build ${c30609_1.build} is older than ${UPDATE_CONFIG.currentBuild}`);
r106 = null;
}
return r106;
}
return null;
}
export function openBuildInstaller(a0) {
openBuildInstallerUrl(a0.urls.install);
}
export { openBuildInstallerUrl };