Symbol Menu: Fix closing on iOS; Sticker Tooltip: Fix sticker autocomplete on iOS (#1441)

This commit is contained in:
Alexander Zinchuk 2021-09-16 11:27:09 +03:00
parent 8192836662
commit f732a72e60
2 changed files with 6 additions and 3 deletions

View File

@ -15,6 +15,7 @@
padding-right: env(safe-area-inset-right);
padding-bottom: env(safe-area-inset-bottom);
padding-left: env(safe-area-inset-left);
transform: translate3d(0, calc(var(--symbol-menu-height) + var(--symbol-menu-footer-height) + env(safe-area-inset-bottom)), 0);
}
&.open {

View File

@ -1,4 +1,4 @@
import { useEffect } from '../../../../lib/teact/teact';
import { useEffect, useMemo } from '../../../../lib/teact/teact';
import { getDispatch } from '../../../../lib/teact/teactn';
import { ApiSticker } from '../../../../api/types';
@ -6,6 +6,7 @@ import { ApiSticker } from '../../../../api/types';
import { IS_EMOJI_SUPPORTED } from '../../../../util/environment';
import parseEmojiOnlyString from '../../../common/helpers/parseEmojiOnlyString';
import { prepareForRegExp } from '../helpers/prepareForRegExp';
export default function useStickerTooltip(
isAllowed: boolean,
@ -13,9 +14,10 @@ export default function useStickerTooltip(
stickers?: ApiSticker[],
isDisabled = false,
) {
const cleanHtml = useMemo(() => prepareForRegExp(html).trim(), [html]);
const { loadStickersForEmoji, clearStickersForEmoji } = getDispatch();
const isSingleEmoji = (
(IS_EMOJI_SUPPORTED && parseEmojiOnlyString(html) === 1)
(IS_EMOJI_SUPPORTED && parseEmojiOnlyString(cleanHtml) === 1)
|| (!IS_EMOJI_SUPPORTED && Boolean(html.match(/^<img.[^>]*?>$/g)))
);
const hasStickers = Boolean(stickers) && isSingleEmoji;
@ -24,7 +26,7 @@ export default function useStickerTooltip(
if (isDisabled) return;
if (isAllowed && isSingleEmoji) {
loadStickersForEmoji({ emoji: html });
loadStickersForEmoji({ emoji: cleanHtml });
} else if (hasStickers || !isSingleEmoji) {
clearStickersForEmoji();
}