diff --git a/src/components/modals/webApp/MoreAppsTabContent.tsx b/src/components/modals/webApp/MoreAppsTabContent.tsx index b34681374..34dbecc45 100644 --- a/src/components/modals/webApp/MoreAppsTabContent.tsx +++ b/src/components/modals/webApp/MoreAppsTabContent.tsx @@ -20,7 +20,7 @@ import useOldLang from '../../../hooks/useOldLang'; import InfiniteScroll from '../../ui/InfiniteScroll'; import SearchInput from '../../ui/SearchInput'; -import WebAppGridItem from './WebAppGridtem'; +import WebAppGridItem from './WebAppGridItem'; import styles from './MoreAppsTabContent.module.scss'; diff --git a/src/components/modals/webApp/WebAppGridtem.tsx b/src/components/modals/webApp/WebAppGridItem.tsx similarity index 100% rename from src/components/modals/webApp/WebAppGridtem.tsx rename to src/components/modals/webApp/WebAppGridItem.tsx diff --git a/src/global/actions/api/chats.ts b/src/global/actions/api/chats.ts index 3625f5c24..02d849a45 100644 --- a/src/global/actions/api/chats.ts +++ b/src/global/actions/api/chats.ts @@ -32,7 +32,7 @@ import { TOPICS_SLICE_SECOND_LOAD, } from '../../../config'; import { copyTextToClipboard } from '../../../util/clipboard'; -import { formatShareText, parseChooseParameter, processDeepLink } from '../../../util/deeplink'; +import { formatShareText, processDeepLink } from '../../../util/deeplink'; import { isDeepLink } from '../../../util/deepLinkParser'; import { getCurrentTabId } from '../../../util/establishMultitabRole'; import { getOrderedIds } from '../../../util/folderManager'; @@ -1282,7 +1282,6 @@ addActionHandler('openTelegramLink', async (global, actions, payload): Promise => { const { username, messageId, commentId, startParam, startAttach, attach, threadId, originalParts, startApp, - text, onChatChanged, + text, onChatChanged, choose, tabId = getCurrentTabId(), } = payload; @@ -1519,6 +1508,17 @@ addActionHandler('openChatByUsername', async (global, actions, payload): Promise }); return; } + + if (startAttach !== undefined && choose) { + actions.processAttachBotParameters({ + username, + filter: choose, + startParam: startAttach || startApp, + tabId, + }); + return; + } + if (startApp !== undefined && !webAppName) { const theme = extractCurrentThemeParams(); const chatByUsername = await fetchChatByUsername(global, username); diff --git a/src/global/types.ts b/src/global/types.ts index 65f91db3c..bf9b01de5 100644 --- a/src/global/types.ts +++ b/src/global/types.ts @@ -1836,6 +1836,7 @@ export interface ActionPayloads { startAttach?: string; attach?: string; startApp?: string; + choose?: ApiChatType[]; text?: string; originalParts?: (string | undefined)[]; onChatChanged?: CallbackAction; diff --git a/src/util/deepLinkParser.ts b/src/util/deepLinkParser.ts index d43c3c46f..b68de1cb4 100644 --- a/src/util/deepLinkParser.ts +++ b/src/util/deepLinkParser.ts @@ -65,6 +65,7 @@ interface PublicUsernameOrBotLink { startAttach?: string; attach?: string; text?: string; + choose?: string; } interface BusinessChatLink { @@ -202,6 +203,7 @@ function parseTgLink(url: URL) { startApp: queryParams.startapp, startAttach: queryParams.startattach, attach: queryParams.attach, + choose: queryParams.choose, }); case 'businessChatLink': return buildBusinessChatLink({ slug: queryParams.slug }); @@ -294,6 +296,7 @@ function parseHttpLink(url: URL) { appName: undefined, startAttach: queryParams.startattach, attach: queryParams.attach, + choose: queryParams.choose, }); case 'businessChatLink': return buildBusinessChatLink({ slug: pathParams[1] }); @@ -523,6 +526,7 @@ function buildPublicUsernameOrBotLink( startAttach, attach, appName, + choose, } = params; if (!username) { return undefined; @@ -539,6 +543,7 @@ function buildPublicUsernameOrBotLink( startAttach, attach, text, + choose, }; } diff --git a/src/util/deeplink.ts b/src/util/deeplink.ts index 53a549c91..ba4246d9f 100644 --- a/src/util/deeplink.ts +++ b/src/util/deeplink.ts @@ -17,7 +17,9 @@ export const processDeepLink = (url: string): boolean => { case 'privateMessageLink': handlePrivateMessageLink(parsedLink, actions); return true; - case 'publicUsernameOrBotLink': + case 'publicUsernameOrBotLink': { + const choose = parseChooseParameter(parsedLink.choose); + actions.openChatByUsername({ username: parsedLink.username, startParam: parsedLink.start, @@ -25,9 +27,11 @@ export const processDeepLink = (url: string): boolean => { startApp: parsedLink.startApp, startAttach: parsedLink.startAttach, attach: parsedLink.attach, + choose, originalParts: [parsedLink.username, parsedLink.appName], }); return true; + } case 'businessChatLink': actions.resolveBusinessChatLink({ slug: parsedLink.slug, @@ -65,7 +69,6 @@ export const processDeepLink = (url: string): boolean => { openStickerSet, joinVoiceChatByLink, openInvoice, - processAttachBotParameters, openChatWithDraft, checkChatlistInvite, openStoryViewerByUsername, @@ -81,10 +84,7 @@ export const processDeepLink = (url: string): boolean => { appname, startapp, story, text, } = params; - const hasStartAttach = params.hasOwnProperty('startattach'); - const hasStartApp = params.hasOwnProperty('startapp'); const hasBoost = params.hasOwnProperty('boost'); - const choose = parseChooseParameter(params.choose); const threadId = Number(thread) || Number(topic) || undefined; if (domain !== 'telegrampassport') { @@ -95,12 +95,6 @@ export const processDeepLink = (url: string): boolean => { originalParts: [domain, appname], text, }); - } else if ((hasStartAttach && choose) || (!appname && hasStartApp)) { - processAttachBotParameters({ - username: domain, - filter: choose, - startParam: startattach || startapp, - }); } else if (params.hasOwnProperty('voicechat') || params.hasOwnProperty('livestream')) { joinVoiceChatByLink({ username: domain, @@ -206,12 +200,6 @@ export const processDeepLink = (url: string): boolean => { return true; }; -export function parseChooseParameter(choose?: string) { - if (!choose) return undefined; - const types = choose.toLowerCase().split(' '); - return types.filter((type): type is ApiChatType => API_CHAT_TYPES.includes(type as ApiChatType)); -} - export function formatShareText(url?: string, text?: string, title?: string): ApiFormattedText { return { text: [url, title, text].filter(Boolean).join('\n'), @@ -236,3 +224,9 @@ function handlePrivateMessageLink(link: PrivateMessageLink, actions: ReturnType< messageId, }); } + +function parseChooseParameter(choose?: string) { + if (!choose) return undefined; + const types = choose.toLowerCase().split(' '); + return types.filter((type): type is ApiChatType => API_CHAT_TYPES.includes(type as ApiChatType)); +}