diff --git a/src/components/middle/composer/InlineBotTooltip.tsx b/src/components/middle/composer/InlineBotTooltip.tsx index d655d375b..e4b64abeb 100644 --- a/src/components/middle/composer/InlineBotTooltip.tsx +++ b/src/components/middle/composer/InlineBotTooltip.tsx @@ -124,7 +124,7 @@ const InlineBotTooltip: FC = ({ ); const renderedInlineBotResults = inlineBotResults?.length ? inlineBotResults : prevInlineBotResults; - if (!shouldRender || !(renderedInlineBotResults?.length || switchPm)) { + if (!shouldRender || !(renderedInlineBotResults?.length || switchPm || switchWebview)) { return undefined; } diff --git a/src/components/middle/composer/hooks/useInlineBotTooltip.ts b/src/components/middle/composer/hooks/useInlineBotTooltip.ts index 11e73e33e..752a5154a 100644 --- a/src/components/middle/composer/hooks/useInlineBotTooltip.ts +++ b/src/components/middle/composer/hooks/useInlineBotTooltip.ts @@ -68,7 +68,7 @@ export default function useInlineBotTooltip( help, } = (usernameLowered && inlineBots?.[usernameLowered]) || {}; - const isOpen = Boolean((results?.length || switchPm) && !isManuallyClosed); + const isOpen = Boolean((results?.length || switchPm || switchWebview) && !isManuallyClosed); useEffect(() => { if (!isOpen && !username) { diff --git a/src/global/actions/api/bots.ts b/src/global/actions/api/bots.ts index 9a2e21af5..b5c9d0a1e 100644 --- a/src/global/actions/api/bots.ts +++ b/src/global/actions/api/bots.ts @@ -18,6 +18,7 @@ import { BOT_FATHER_USERNAME, GENERAL_REFETCH_INTERVAL } from '../../../config'; import { copyTextToClipboard } from '../../../util/clipboard'; import { getUsernameFromDeepLink } from '../../../util/deepLinkParser'; import { getCurrentTabId } from '../../../util/establishMultitabRole'; +import { pick } from '../../../util/iteratees.ts'; import { getTranslationFn } from '../../../util/localization'; import { formatStarsAsText } from '../../../util/localization/format'; import { oldTranslate } from '../../../util/oldLangProvider'; @@ -29,7 +30,7 @@ import { callApi } from '../../../api/gramjs'; import { getMainUsername } from '../../helpers'; import { getWebAppKey, -} from '../../helpers/bots'; +} from '../../helpers'; import { addActionHandler, getGlobal, setGlobal, } from '../../index'; @@ -1246,27 +1247,25 @@ async function searchInlineBot(global: T, { }); global = getGlobal(); - const newInlineBotData = selectTabState(global, tabId).inlineBots.byUsername[username]; + const currentInlineBotSettings = selectTabState(global, tabId).inlineBots.byUsername[username]; global = replaceInlineBotsIsLoading(global, false, tabId); - if (!result || !newInlineBotData || query !== newInlineBotData.query) { + if (!result || !currentInlineBotSettings || query !== currentInlineBotSettings.query) { setGlobal(global); return; } - const currentIds = new Set((newInlineBotData.results || []).map((data) => data.id)); + const currentIds = new Set((currentInlineBotSettings.results || []).map((data) => data.id)); const newResults = result.results.filter((data) => !currentIds.has(data.id)); global = replaceInlineBotSettings(global, username, { - ...newInlineBotData, - help: result.help, + ...currentInlineBotSettings, + ...pick(result, ['help', 'switchPm', 'switchWebview']), cacheTime: Date.now() + result.cacheTime * 1000, ...(newResults.length && { isGallery: result.isGallery }), - ...(result.switchPm && { switchPm: result.switchPm }), - ...(result.switchWebview && { switchWebview: result.switchWebview }), canLoadMore: result.results.length > 0 && Boolean(result.nextOffset), - results: newInlineBotData.offset === '' || newInlineBotData.offset === result.nextOffset + results: currentInlineBotSettings.offset === '' || currentInlineBotSettings.offset === result.nextOffset ? result.results - : (newInlineBotData.results || []).concat(newResults), + : (currentInlineBotSettings.results || []).concat(newResults), offset: newResults.length ? result.nextOffset : '', }, tabId); diff --git a/src/global/types/actions.ts b/src/global/types/actions.ts index 7c1ba9adb..3ba75791c 100644 --- a/src/global/types/actions.ts +++ b/src/global/types/actions.ts @@ -10,6 +10,8 @@ import type { ApiChatType, ApiDisallowedGiftsSettings, ApiDraft, + ApiEmojiStatusCollectible, + ApiEmojiStatusType, ApiExportedInvite, ApiFormattedText, ApiGeoPoint, @@ -58,7 +60,6 @@ import type { LinkContext, PrivacyVisibility, } from '../../api/types'; -import type { ApiEmojiStatusCollectible, ApiEmojiStatusType } from '../../api/types/users'; import type { ApiCredentials } from '../../components/payment/PaymentModal'; import type { FoldersActions } from '../../hooks/reducers/useFoldersReducer'; import type { ReducerAction } from '../../hooks/useReducer';