Sticker Tooltip: Fix flickering on multitab instance (#3011)

This commit is contained in:
Alexander Zinchuk 2023-04-19 04:08:42 +02:00
parent 3423b63e9c
commit b1a34ee4d3

View File

@ -148,6 +148,7 @@ type OwnProps = {
type StateProps = type StateProps =
{ {
isOnActiveTab: boolean;
editingMessage?: ApiMessage; editingMessage?: ApiMessage;
chat?: ApiChat; chat?: ApiChat;
draft?: ApiDraft; draft?: ApiDraft;
@ -222,6 +223,7 @@ const SENDING_ANIMATION_DURATION = 350;
const APPENDIX = '<svg width="9" height="20" xmlns="http://www.w3.org/2000/svg"><defs><filter x="-50%" y="-14.7%" width="200%" height="141.2%" filterUnits="objectBoundingBox" id="a"><feOffset dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur stdDeviation="1" in="shadowOffsetOuter1" result="shadowBlurOuter1"/><feColorMatrix values="0 0 0 0 0.0621962482 0 0 0 0 0.138574144 0 0 0 0 0.185037364 0 0 0 0.15 0" in="shadowBlurOuter1"/></filter></defs><g fill="none" fill-rule="evenodd"><path d="M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z" fill="#000" filter="url(#a)"/><path d="M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z" fill="#FFF" class="corner"/></g></svg>'; const APPENDIX = '<svg width="9" height="20" xmlns="http://www.w3.org/2000/svg"><defs><filter x="-50%" y="-14.7%" width="200%" height="141.2%" filterUnits="objectBoundingBox" id="a"><feOffset dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur stdDeviation="1" in="shadowOffsetOuter1" result="shadowBlurOuter1"/><feColorMatrix values="0 0 0 0 0.0621962482 0 0 0 0 0.138574144 0 0 0 0 0.185037364 0 0 0 0.15 0" in="shadowBlurOuter1"/></filter></defs><g fill="none" fill-rule="evenodd"><path d="M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z" fill="#000" filter="url(#a)"/><path d="M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z" fill="#FFF" class="corner"/></g></svg>';
const Composer: FC<OwnProps & StateProps> = ({ const Composer: FC<OwnProps & StateProps> = ({
isOnActiveTab,
dropAreaState, dropAreaState,
shouldSchedule, shouldSchedule,
canScheduleUntilOnline, canScheduleUntilOnline,
@ -429,7 +431,7 @@ const Composer: FC<OwnProps & StateProps> = ({
filteredCustomEmojis, filteredCustomEmojis,
insertEmoji, insertEmoji,
} = useEmojiTooltip( } = useEmojiTooltip(
Boolean(isReady && isForCurrentMessageList && shouldSuggestStickers && !hasAttachments), Boolean(isReady && isOnActiveTab && isForCurrentMessageList && shouldSuggestStickers && !hasAttachments),
getHtml, getHtml,
setHtml, setHtml,
undefined, undefined,
@ -443,7 +445,7 @@ const Composer: FC<OwnProps & StateProps> = ({
closeCustomEmojiTooltip, closeCustomEmojiTooltip,
insertCustomEmoji, insertCustomEmoji,
} = useCustomEmojiTooltip( } = useCustomEmojiTooltip(
Boolean(isReady && isForCurrentMessageList && shouldSuggestCustomEmoji && !hasAttachments), Boolean(isReady && isOnActiveTab && isForCurrentMessageList && shouldSuggestCustomEmoji && !hasAttachments),
getHtml, getHtml,
setHtml, setHtml,
getSelectionRange, getSelectionRange,
@ -455,7 +457,12 @@ const Composer: FC<OwnProps & StateProps> = ({
isStickerTooltipOpen, isStickerTooltipOpen,
closeStickerTooltip, closeStickerTooltip,
} = useStickerTooltip( } = useStickerTooltip(
Boolean(isReady && isForCurrentMessageList && shouldSuggestStickers && canSendStickers && !hasAttachments), Boolean(isReady
&& isOnActiveTab
&& isForCurrentMessageList
&& shouldSuggestStickers
&& canSendStickers
&& !hasAttachments),
getHtml, getHtml,
stickersForEmoji, stickersForEmoji,
); );
@ -1582,6 +1589,7 @@ export default memo(withGlobal<OwnProps>(
const tabState = selectTabState(global); const tabState = selectTabState(global);
return { return {
isOnActiveTab: !tabState.isBlurred,
editingMessage: selectEditingMessage(global, chatId, threadId, messageListType), editingMessage: selectEditingMessage(global, chatId, threadId, messageListType),
connectionState: global.connectionState, connectionState: global.connectionState,
replyingToId, replyingToId,