fix: paje refresh crush
All checks were successful
Deploy to VPS (dist) / deploy (push) Successful in 1m35s

This commit is contained in:
Hewston Fox
2026-03-18 21:18:15 +02:00
parent 1cadf7f1d2
commit c74643263a

View File

@@ -5,13 +5,10 @@ export const STORAGE_KEYS = {
} as const;
export type StorageKey = (typeof STORAGE_KEYS)[keyof typeof STORAGE_KEYS];
const isRealTelegram = () => {
if (typeof window === "undefined") return false;
const search = location.hash.slice(1) || location.search.slice(1);
return search.includes("tgWebAppData");
};
// @ts-expect-error Just for an initial check
const IS_REAL_TG = Boolean(window?.Telegram?.WebApp);
if (!isRealTelegram()) {
if (!IS_REAL_TG) {
tg.mockTelegramEnv({
launchParams: {
tgWebAppData: new URLSearchParams({
@@ -61,7 +58,7 @@ const fallbackImplementation = <
cb: T,
onErr: F,
): Async extends true ? Promise<Result> : Awaited<Result> => {
if (isRealTelegram()) {
if (IS_REAL_TG) {
const res = cb.ifAvailable.apply(null, args);
const returnValue = (res.ok ? res.data : onErr.apply(null, args)) as Result;
if (!async) return returnValue as Async extends true ? Promise<Result> : Awaited<Result>;
@@ -84,9 +81,7 @@ export default {
tg.swipeBehavior.disableVertical.ifAvailable();
tg.viewport.expand.ifAvailable();
tg.miniApp.setHeaderColor.ifAvailable("#000000");
console.log(
isRealTelegram() ? "Telegram Mini App initialized" : "TMA Debug mode in Web initialized",
);
console.log(IS_REAL_TG ? "Telegram Mini App initialized" : "TMA Debug mode in Web initialized");
console.log(tg.retrieveLaunchParams());
},
openLink(url: string | URL, options?: tg.OpenLinkOptions) {