Support tg://ton link

This commit is contained in:
Alexander Zinchuk 2025-07-29 14:33:46 +02:00
parent c6c2336a66
commit 9b9706bda7
2 changed files with 14 additions and 2 deletions

View File

@ -10,7 +10,7 @@ import { isUsernameValid } from './entities/username';
export type DeepLinkMethod = 'resolve' | 'login' | 'passport' | 'settings' | 'join' | 'addstickers' | 'addemoji' |
'setlanguage' | 'addtheme' | 'confirmphone' | 'socks' | 'proxy' | 'privatepost' | 'bg' | 'share' | 'msg' | 'msg_url' |
'invoice' | 'addlist' | 'boost' | 'giftcode' | 'message' | 'premium_offer' | 'premium_multigift' | 'stars_topup'
| 'nft' | 'stars';
| 'nft' | 'stars' | 'ton';
interface PublicMessageLink {
type: 'publicMessageLink';
@ -107,6 +107,10 @@ interface StarsModalLink {
type: 'stars';
}
interface TonModalLink {
type: 'ton';
}
interface SettingsScreenLink {
type: 'settings';
screen?: 'devices' | 'folders' | 'language' | 'privacy' | 'editProfile' | 'theme';
@ -127,6 +131,7 @@ type DeepLink =
ChatBoostLink |
GiftUniqueLink |
StarsModalLink |
TonModalLink |
SettingsScreenLink;
type BuilderParams<T extends DeepLink> = Record<keyof Omit<T, 'type'>, string | undefined>;
@ -260,6 +265,8 @@ function parseTgLink(url: URL) {
return buildGiftUniqueLink({ slug: queryParams.slug });
case 'stars':
return { type: 'stars' } satisfies StarsModalLink;
case 'ton':
return { type: 'ton' } satisfies TonModalLink;
case 'settings':
return buildSettingsScreenLink({ screen: pathParams.length === 1 ? pathParams[0] : undefined });
default:
@ -469,6 +476,8 @@ function getTgDeepLinkType(
return 'giftUniqueLink';
case 'stars':
return 'stars';
case 'ton':
return 'ton';
case 'settings': {
return 'settings';
}

View File

@ -4,7 +4,7 @@ import type { ApiChatType, ApiFormattedText } from '../api/types';
import type { DeepLinkMethod } from './deepLinkParser';
import { LeftColumnContent, SettingsScreens } from '../types';
import { API_CHAT_TYPES, RE_TG_LINK } from '../config';
import { API_CHAT_TYPES, RE_TG_LINK, TON_CURRENCY_CODE } from '../config';
import { IS_BAD_URL_PARSER } from './browser/globalEnvironment';
import { tryParseDeepLink } from './deepLinkParser';
@ -105,6 +105,9 @@ export const processDeepLink = (url: string): boolean => {
case 'stars':
actions.openStarsBalanceModal({});
break;
case 'ton':
actions.openStarsBalanceModal({ currency: TON_CURRENCY_CODE });
break;
default:
break;
}