- Updated CSS to utilize viewport variables for safe area insets and stable height, improving layout consistency across devices. - Introduced haptic feedback triggers in various components to enhance user interaction, mimicking native Telegram behavior. - Added functionality to detect Android performance class, minimizing animations on low-performance devices for better user experience. - Refactored components to incorporate new CSS classes for content safety and improved responsiveness.
31 lines
912 B
TypeScript
31 lines
912 B
TypeScript
/**
|
|
* Single-call wrapper for Telegram Mini App ready() and expand().
|
|
* Called once when the first visible screen has finished loading so Telegram
|
|
* hides its native loading animation only after our content is ready.
|
|
* Also expands the Mini App to full height when supported.
|
|
*/
|
|
|
|
import { miniAppReady, expandViewport } from "@telegram-apps/sdk-react";
|
|
|
|
let readyCalled = false;
|
|
|
|
/**
|
|
* Calls Telegram miniAppReady() at most once per session, then expandViewport()
|
|
* when available so the app opens to full height.
|
|
* Safe when SDK is unavailable (e.g. non-Telegram environment).
|
|
*/
|
|
export function callMiniAppReadyOnce(): void {
|
|
if (readyCalled) return;
|
|
try {
|
|
if (miniAppReady.isAvailable()) {
|
|
miniAppReady();
|
|
readyCalled = true;
|
|
}
|
|
if (expandViewport.isAvailable()) {
|
|
expandViewport();
|
|
}
|
|
} catch {
|
|
// SDK not available or not in Mini App context; no-op.
|
|
}
|
|
}
|