diff --git a/ui/src/components/StaleInviteModal.svelte b/ui/src/components/StaleInviteModal.svelte index d38259b..ec60d8e 100644 --- a/ui/src/components/StaleInviteModal.svelte +++ b/ui/src/components/StaleInviteModal.svelte @@ -11,10 +11,6 @@ // Split the message around the {bot} token so the bot handle renders as an inline link. const parts = $derived(t('friends.staleInvite').split('{bot}')); - // Inside the Mini App with native popups, present the notice as Telegram's own popup instead of - // the in-app modal. - const useNative = insideTelegram() && telegramDialogsAvailable(); - function openBot() { if (username) { const url = `https://t.me/${username}`; @@ -25,12 +21,14 @@ dismissStaleInvite(); } - // Native path: raise Telegram's popup when the notice appears; its "open bot" button opens the - // bot chat, any other dismissal just clears the notice. The `shown` guard fires it once per notice. + // Native path: when the notice fires inside the Mini App with native popups, present Telegram's + // own popup instead of the in-app modal. insideTelegram()/dialogs are evaluated at fire time, not + // captured at init: this component mounts before bootstrap loads the SDK, so a captured value + // would be stale. The popup's "open bot" button opens the bot chat; any other dismissal clears the + // notice; the `shown` guard fires it once per notice. let shown = false; $effect(() => { - if (!useNative) return; - if (app.staleInvite && !shown) { + if (app.staleInvite && !shown && insideTelegram() && telegramDialogsAvailable()) { shown = true; void telegramShowPopup( botInfoPopup(t('friends.staleInviteTitle'), t('friends.staleInvite'), username ?? '', t('common.ok')), @@ -41,7 +39,7 @@ }); -{#if app.staleInvite && !useNative} +{#if app.staleInvite && !(insideTelegram() && telegramDialogsAvailable())}

{parts[0]}{#if username}{/if}{parts[1] ?? ''}

diff --git a/ui/src/components/WelcomeRedeemModal.svelte b/ui/src/components/WelcomeRedeemModal.svelte index a57f517..e7f58a0 100644 --- a/ui/src/components/WelcomeRedeemModal.svelte +++ b/ui/src/components/WelcomeRedeemModal.svelte @@ -14,10 +14,6 @@ // as an inline link (the {name} value is substituted first; {bot} is left for the split). const parts = $derived(t('friends.welcomeRedeem', { name }).split('{bot}')); - // Inside the Mini App with native popups, present the greeting as Telegram's own popup instead of - // the in-app modal. - const useNative = insideTelegram() && telegramDialogsAvailable(); - function openBot() { if (username) { const url = `https://t.me/${username}`; @@ -28,12 +24,14 @@ dismissWelcomeRedeem(); } - // Native path: raise Telegram's popup when the greeting appears; its "open bot" button opens the - // bot chat, any other dismissal just clears it. The `shown` guard fires it once per greeting. + // Native path: when the greeting fires inside the Mini App with native popups, present Telegram's + // own popup instead of the in-app modal. insideTelegram()/dialogs are evaluated at fire time, not + // captured at init: this component mounts before bootstrap loads the SDK, so a captured value + // would be stale. The popup's "open bot" button opens the bot chat; any other dismissal clears it; + // the `shown` guard fires it once per greeting. let shown = false; $effect(() => { - if (!useNative) return; - if (app.welcomeRedeem && !shown) { + if (app.welcomeRedeem && !shown && insideTelegram() && telegramDialogsAvailable()) { shown = true; void telegramShowPopup( botInfoPopup(t('friends.welcomeRedeemTitle'), t('friends.welcomeRedeem', { name }), username ?? '', t('common.ok')), @@ -44,7 +42,7 @@ }); -{#if app.welcomeRedeem && !useNative} +{#if app.welcomeRedeem && !(insideTelegram() && telegramDialogsAvailable())}

{parts[0]}{#if username}{/if}{parts[1] ?? ''}