Composer / Inline Bot Tooltip: Various fixes
This commit is contained in:
parent
9f6bd9376a
commit
98212de7aa
@ -124,7 +124,7 @@ const InlineBotTooltip: FC<OwnProps> = ({
|
|||||||
);
|
);
|
||||||
const renderedInlineBotResults = inlineBotResults?.length ? inlineBotResults : prevInlineBotResults;
|
const renderedInlineBotResults = inlineBotResults?.length ? inlineBotResults : prevInlineBotResults;
|
||||||
|
|
||||||
if (!shouldRender || !(renderedInlineBotResults?.length || switchPm)) {
|
if (!shouldRender || !(renderedInlineBotResults?.length || switchPm || switchWebview)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -68,7 +68,7 @@ export default function useInlineBotTooltip(
|
|||||||
help,
|
help,
|
||||||
} = (usernameLowered && inlineBots?.[usernameLowered]) || {};
|
} = (usernameLowered && inlineBots?.[usernameLowered]) || {};
|
||||||
|
|
||||||
const isOpen = Boolean((results?.length || switchPm) && !isManuallyClosed);
|
const isOpen = Boolean((results?.length || switchPm || switchWebview) && !isManuallyClosed);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isOpen && !username) {
|
if (!isOpen && !username) {
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import { BOT_FATHER_USERNAME, GENERAL_REFETCH_INTERVAL } from '../../../config';
|
|||||||
import { copyTextToClipboard } from '../../../util/clipboard';
|
import { copyTextToClipboard } from '../../../util/clipboard';
|
||||||
import { getUsernameFromDeepLink } from '../../../util/deepLinkParser';
|
import { getUsernameFromDeepLink } from '../../../util/deepLinkParser';
|
||||||
import { getCurrentTabId } from '../../../util/establishMultitabRole';
|
import { getCurrentTabId } from '../../../util/establishMultitabRole';
|
||||||
|
import { pick } from '../../../util/iteratees.ts';
|
||||||
import { getTranslationFn } from '../../../util/localization';
|
import { getTranslationFn } from '../../../util/localization';
|
||||||
import { formatStarsAsText } from '../../../util/localization/format';
|
import { formatStarsAsText } from '../../../util/localization/format';
|
||||||
import { oldTranslate } from '../../../util/oldLangProvider';
|
import { oldTranslate } from '../../../util/oldLangProvider';
|
||||||
@ -29,7 +30,7 @@ import { callApi } from '../../../api/gramjs';
|
|||||||
import { getMainUsername } from '../../helpers';
|
import { getMainUsername } from '../../helpers';
|
||||||
import {
|
import {
|
||||||
getWebAppKey,
|
getWebAppKey,
|
||||||
} from '../../helpers/bots';
|
} from '../../helpers';
|
||||||
import {
|
import {
|
||||||
addActionHandler, getGlobal, setGlobal,
|
addActionHandler, getGlobal, setGlobal,
|
||||||
} from '../../index';
|
} from '../../index';
|
||||||
@ -1246,27 +1247,25 @@ async function searchInlineBot<T extends GlobalState>(global: T, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
global = getGlobal();
|
global = getGlobal();
|
||||||
const newInlineBotData = selectTabState(global, tabId).inlineBots.byUsername[username];
|
const currentInlineBotSettings = selectTabState(global, tabId).inlineBots.byUsername[username];
|
||||||
global = replaceInlineBotsIsLoading(global, false, tabId);
|
global = replaceInlineBotsIsLoading(global, false, tabId);
|
||||||
if (!result || !newInlineBotData || query !== newInlineBotData.query) {
|
if (!result || !currentInlineBotSettings || query !== currentInlineBotSettings.query) {
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
return;
|
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));
|
const newResults = result.results.filter((data) => !currentIds.has(data.id));
|
||||||
|
|
||||||
global = replaceInlineBotSettings(global, username, {
|
global = replaceInlineBotSettings(global, username, {
|
||||||
...newInlineBotData,
|
...currentInlineBotSettings,
|
||||||
help: result.help,
|
...pick(result, ['help', 'switchPm', 'switchWebview']),
|
||||||
cacheTime: Date.now() + result.cacheTime * 1000,
|
cacheTime: Date.now() + result.cacheTime * 1000,
|
||||||
...(newResults.length && { isGallery: result.isGallery }),
|
...(newResults.length && { isGallery: result.isGallery }),
|
||||||
...(result.switchPm && { switchPm: result.switchPm }),
|
|
||||||
...(result.switchWebview && { switchWebview: result.switchWebview }),
|
|
||||||
canLoadMore: result.results.length > 0 && Boolean(result.nextOffset),
|
canLoadMore: result.results.length > 0 && Boolean(result.nextOffset),
|
||||||
results: newInlineBotData.offset === '' || newInlineBotData.offset === result.nextOffset
|
results: currentInlineBotSettings.offset === '' || currentInlineBotSettings.offset === result.nextOffset
|
||||||
? result.results
|
? result.results
|
||||||
: (newInlineBotData.results || []).concat(newResults),
|
: (currentInlineBotSettings.results || []).concat(newResults),
|
||||||
offset: newResults.length ? result.nextOffset : '',
|
offset: newResults.length ? result.nextOffset : '',
|
||||||
}, tabId);
|
}, tabId);
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import type {
|
|||||||
ApiChatType,
|
ApiChatType,
|
||||||
ApiDisallowedGiftsSettings,
|
ApiDisallowedGiftsSettings,
|
||||||
ApiDraft,
|
ApiDraft,
|
||||||
|
ApiEmojiStatusCollectible,
|
||||||
|
ApiEmojiStatusType,
|
||||||
ApiExportedInvite,
|
ApiExportedInvite,
|
||||||
ApiFormattedText,
|
ApiFormattedText,
|
||||||
ApiGeoPoint,
|
ApiGeoPoint,
|
||||||
@ -58,7 +60,6 @@ import type {
|
|||||||
LinkContext,
|
LinkContext,
|
||||||
PrivacyVisibility,
|
PrivacyVisibility,
|
||||||
} from '../../api/types';
|
} from '../../api/types';
|
||||||
import type { ApiEmojiStatusCollectible, ApiEmojiStatusType } from '../../api/types/users';
|
|
||||||
import type { ApiCredentials } from '../../components/payment/PaymentModal';
|
import type { ApiCredentials } from '../../components/payment/PaymentModal';
|
||||||
import type { FoldersActions } from '../../hooks/reducers/useFoldersReducer';
|
import type { FoldersActions } from '../../hooks/reducers/useFoldersReducer';
|
||||||
import type { ReducerAction } from '../../hooks/useReducer';
|
import type { ReducerAction } from '../../hooks/useReducer';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user