feat(telegram): native dialogs for confirms and deep-link notices
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 10s
CI / integration (pull_request) Successful in 15s
CI / ui (pull_request) Successful in 56s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m19s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 10s
CI / integration (pull_request) Successful in 15s
CI / ui (pull_request) Successful in 56s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m19s
Inside the Mini App, route the destructive confirmations (resign, block, unfriend) through Telegram's native showConfirm, and present the deep-link info modals (stale invite, welcome-on-redeem) as a native showPopup whose button opens the bot chat. Outside Telegram, or on a client predating the dialogs, the existing in-app Modal is used unchanged; offline also keeps the modal so the action retains its disabled state. Adds showConfirm/showPopup wrappers to telegram.ts and a pure popup-params builder (nativedialogs.ts) with unit tests; the deep-link modal components choose native vs in-app via an effect gated on insideTelegram + dialog availability.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// Pure builder for the Telegram native popup (showPopup) used by the deep-link info modals
|
||||
// (StaleInviteModal / WelcomeRedeemModal) inside the Mini App. Kept free of the SDK and the DOM so
|
||||
// it unit-tests in the node environment; the showPopup transport wrapper lives in telegram.ts and
|
||||
// the wiring (native inside Telegram, the in-app Modal elsewhere) in the modal components.
|
||||
|
||||
import type { TelegramPopupParams } from './telegram';
|
||||
|
||||
/** BOT_BUTTON_ID is the showPopup button id that means "open the bot chat". */
|
||||
export const BOT_BUTTON_ID = 'bot';
|
||||
|
||||
/**
|
||||
* botInfoPopup builds the native popup for a deep-link info modal: the message with the `{bot}`
|
||||
* token replaced by the `@username` as plain text (a native popup has no inline link, unlike the
|
||||
* in-app Modal), plus an "open bot" button when a username is known and a closing OK button. With
|
||||
* no username it is the message (token removed) and OK only.
|
||||
*/
|
||||
export function botInfoPopup(title: string, message: string, username: string, okText: string): TelegramPopupParams {
|
||||
const handle = username ? `@${username}` : '';
|
||||
const text = (username ? message.replace('{bot}', handle) : message.replace('{bot}', '').replace(' ', ' ')).trim();
|
||||
const buttons = username
|
||||
? [{ id: BOT_BUTTON_ID, text: handle }, { id: 'ok', text: okText }]
|
||||
: [{ id: 'ok', text: okText }];
|
||||
return { title, message: text, buttons };
|
||||
}
|
||||
Reference in New Issue
Block a user