diff --git a/src/components/middle/composer/Composer.tsx b/src/components/middle/composer/Composer.tsx index 12125cbd9..a8f9dd045 100644 --- a/src/components/middle/composer/Composer.tsx +++ b/src/components/middle/composer/Composer.tsx @@ -786,12 +786,10 @@ const Composer: FC = ({ return; } - const attachBot = attachBots[chatId]; - callAttachBot({ - bot: attachBot, chatId, isFromBotMenu: true, url: botMenuButton.url, threadId, + chatId, url: botMenuButton.url, threadId, }); - }, [attachBots, botMenuButton, callAttachBot, chatId, threadId]); + }, [botMenuButton, callAttachBot, chatId, threadId]); const handleActivateBotCommandMenu = useCallback(() => { closeSymbolMenu(); diff --git a/src/global/actions/api/bots.ts b/src/global/actions/api/bots.ts index 2a4366809..cc44a6214 100644 --- a/src/global/actions/api/bots.ts +++ b/src/global/actions/api/bots.ts @@ -592,8 +592,9 @@ async function loadAttachBots(hash?: string) { addActionHandler('callAttachBot', (global, actions, payload) => { const { - chatId, bot, isFromBotMenu, url, startParam, threadId, + chatId, bot, url, startParam, threadId, } = payload; + const isFromBotMenu = !bot; if (!isFromBotMenu && !global.attachMenu.bots[bot.id]) { return { ...global, @@ -611,7 +612,7 @@ addActionHandler('callAttachBot', (global, actions, payload) => { actions.requestWebView({ url, peerId: chatId, - botId: bot.id, + botId: isFromBotMenu ? chatId : bot.id, theme, buttonText: '', isFromBotMenu, diff --git a/src/global/types.ts b/src/global/types.ts index 382c88001..1a8ff9c29 100644 --- a/src/global/types.ts +++ b/src/global/types.ts @@ -1178,8 +1178,7 @@ export interface ActionPayloads { callAttachBot: { chatId: string; threadId?: number; - bot: ApiAttachBot; - isFromBotMenu?: boolean; + bot?: ApiAttachBot; url?: string; startParam?: string; };