Support tg://ton link
This commit is contained in:
parent
c6c2336a66
commit
9b9706bda7
@ -10,7 +10,7 @@ import { isUsernameValid } from './entities/username';
|
|||||||
export type DeepLinkMethod = 'resolve' | 'login' | 'passport' | 'settings' | 'join' | 'addstickers' | 'addemoji' |
|
export type DeepLinkMethod = 'resolve' | 'login' | 'passport' | 'settings' | 'join' | 'addstickers' | 'addemoji' |
|
||||||
'setlanguage' | 'addtheme' | 'confirmphone' | 'socks' | 'proxy' | 'privatepost' | 'bg' | 'share' | 'msg' | 'msg_url' |
|
'setlanguage' | 'addtheme' | 'confirmphone' | 'socks' | 'proxy' | 'privatepost' | 'bg' | 'share' | 'msg' | 'msg_url' |
|
||||||
'invoice' | 'addlist' | 'boost' | 'giftcode' | 'message' | 'premium_offer' | 'premium_multigift' | 'stars_topup'
|
'invoice' | 'addlist' | 'boost' | 'giftcode' | 'message' | 'premium_offer' | 'premium_multigift' | 'stars_topup'
|
||||||
| 'nft' | 'stars';
|
| 'nft' | 'stars' | 'ton';
|
||||||
|
|
||||||
interface PublicMessageLink {
|
interface PublicMessageLink {
|
||||||
type: 'publicMessageLink';
|
type: 'publicMessageLink';
|
||||||
@ -107,6 +107,10 @@ interface StarsModalLink {
|
|||||||
type: 'stars';
|
type: 'stars';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface TonModalLink {
|
||||||
|
type: 'ton';
|
||||||
|
}
|
||||||
|
|
||||||
interface SettingsScreenLink {
|
interface SettingsScreenLink {
|
||||||
type: 'settings';
|
type: 'settings';
|
||||||
screen?: 'devices' | 'folders' | 'language' | 'privacy' | 'editProfile' | 'theme';
|
screen?: 'devices' | 'folders' | 'language' | 'privacy' | 'editProfile' | 'theme';
|
||||||
@ -127,6 +131,7 @@ type DeepLink =
|
|||||||
ChatBoostLink |
|
ChatBoostLink |
|
||||||
GiftUniqueLink |
|
GiftUniqueLink |
|
||||||
StarsModalLink |
|
StarsModalLink |
|
||||||
|
TonModalLink |
|
||||||
SettingsScreenLink;
|
SettingsScreenLink;
|
||||||
|
|
||||||
type BuilderParams<T extends DeepLink> = Record<keyof Omit<T, 'type'>, string | undefined>;
|
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 });
|
return buildGiftUniqueLink({ slug: queryParams.slug });
|
||||||
case 'stars':
|
case 'stars':
|
||||||
return { type: 'stars' } satisfies StarsModalLink;
|
return { type: 'stars' } satisfies StarsModalLink;
|
||||||
|
case 'ton':
|
||||||
|
return { type: 'ton' } satisfies TonModalLink;
|
||||||
case 'settings':
|
case 'settings':
|
||||||
return buildSettingsScreenLink({ screen: pathParams.length === 1 ? pathParams[0] : undefined });
|
return buildSettingsScreenLink({ screen: pathParams.length === 1 ? pathParams[0] : undefined });
|
||||||
default:
|
default:
|
||||||
@ -469,6 +476,8 @@ function getTgDeepLinkType(
|
|||||||
return 'giftUniqueLink';
|
return 'giftUniqueLink';
|
||||||
case 'stars':
|
case 'stars':
|
||||||
return 'stars';
|
return 'stars';
|
||||||
|
case 'ton':
|
||||||
|
return 'ton';
|
||||||
case 'settings': {
|
case 'settings': {
|
||||||
return 'settings';
|
return 'settings';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import type { ApiChatType, ApiFormattedText } from '../api/types';
|
|||||||
import type { DeepLinkMethod } from './deepLinkParser';
|
import type { DeepLinkMethod } from './deepLinkParser';
|
||||||
import { LeftColumnContent, SettingsScreens } from '../types';
|
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 { IS_BAD_URL_PARSER } from './browser/globalEnvironment';
|
||||||
import { tryParseDeepLink } from './deepLinkParser';
|
import { tryParseDeepLink } from './deepLinkParser';
|
||||||
|
|
||||||
@ -105,6 +105,9 @@ export const processDeepLink = (url: string): boolean => {
|
|||||||
case 'stars':
|
case 'stars':
|
||||||
actions.openStarsBalanceModal({});
|
actions.openStarsBalanceModal({});
|
||||||
break;
|
break;
|
||||||
|
case 'ton':
|
||||||
|
actions.openStarsBalanceModal({ currency: TON_CURRENCY_CODE });
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user