diff --git a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp index 366a96e78..e8cd03700 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp @@ -751,7 +751,7 @@ void EmojiListWidget::fillRecent() { continue; } _recent.push_back({ - .custom = resolveCustomEmoji(one.id), + .custom = resolveCustomRecent(one.id), .id = one.id, }); if (document) { @@ -771,7 +771,7 @@ void EmojiListWidget::fillRecentFrom(const std::vector &list) { _recent.reserve(list.size()); for (const auto &id : list) { _recent.push_back({ - .custom = resolveCustomEmoji(id), + .custom = resolveCustomRecent(id), .id = { RecentEmojiDocument{.id = id, .test = test } }, }); _recentCustomIds.emplace(id); @@ -1587,30 +1587,38 @@ not_null EmojiListWidget::resolveCustomEmoji( ).first->second.emoji.get(); } -Ui::Text::CustomEmoji *EmojiListWidget::resolveCustomEmoji( +Ui::Text::CustomEmoji *EmojiListWidget::resolveCustomRecent( RecentEmojiId customId) { const auto &data = customId.data; if (const auto document = std::get_if(&data)) { - return resolveCustomEmoji(document->id); + return resolveCustomRecent(document->id); } else if (const auto emoji = std::get_if(&data)) { return nullptr; } Unexpected("Custom recent emoji id."); } -not_null EmojiListWidget::resolveCustomEmoji( +not_null EmojiListWidget::resolveCustomRecent( DocumentId documentId) { - const auto i = _customEmoji.find(documentId); - if (i != end(_customEmoji)) { - return i->second.emoji.get(); + const auto i = _customRecent.find(documentId); + if (i != end(_customRecent)) { + return i->second.get(); + } + const auto j = _customEmoji.find(documentId); + if (j != end(_customEmoji)) { + return j->second.emoji.get(); } auto repaint = repaintCallback(documentId, RecentEmojiSectionSetId()); - auto custom = _customRecentFactory - ? _customRecentFactory(documentId, std::move(repaint)) - : session().data().customEmojiManager().create( + if (_customRecentFactory) { + return _customRecent.emplace( documentId, - std::move(repaint), - Data::CustomEmojiManager::SizeTag::Large); + _customRecentFactory(documentId, std::move(repaint)) + ).first->second.get(); + } + auto custom = session().data().customEmojiManager().create( + documentId, + std::move(repaint), + Data::CustomEmojiManager::SizeTag::Large); return _customEmoji.emplace( documentId, CustomEmojiInstance{ .emoji = std::move(custom), .recentOnly = true } diff --git a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.h b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.h index 291e08bcb..e733e47d4 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.h +++ b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.h @@ -304,9 +304,9 @@ private: [[nodiscard]] not_null resolveCustomEmoji( not_null document, uint64 setId); - [[nodiscard]] Ui::Text::CustomEmoji *resolveCustomEmoji( + [[nodiscard]] Ui::Text::CustomEmoji *resolveCustomRecent( Core::RecentEmojiId customId); - [[nodiscard]] not_null resolveCustomEmoji( + [[nodiscard]] not_null resolveCustomRecent( DocumentId documentId); [[nodiscard]] Fn repaintCallback( DocumentId documentId, @@ -330,6 +330,9 @@ private: QVector _emoji[kEmojiSectionCount]; std::vector _custom; base::flat_map _customEmoji; + base::flat_map< + DocumentId, + std::unique_ptr> _customRecent; int _customSingleSize = 0; bool _allowWithoutPremium = false; Ui::RoundRect _overBg; diff --git a/Telegram/SourceFiles/history/view/reactions/history_view_reactions_selector.cpp b/Telegram/SourceFiles/history/view/reactions/history_view_reactions_selector.cpp index 0f37c870c..131755295 100644 --- a/Telegram/SourceFiles/history/view/reactions/history_view_reactions_selector.cpp +++ b/Telegram/SourceFiles/history/view/reactions/history_view_reactions_selector.cpp @@ -46,6 +46,7 @@ public: void paint(QPainter &p, const Context &context) override; void unload() override; bool ready() override; + bool readyInDefaultState() override; private: const std::unique_ptr _wrapped; @@ -74,7 +75,8 @@ QString StripEmoji::entityData() { void StripEmoji::paint(QPainter &p, const Context &context) { if (_switched) { _wrapped->paint(p, context); - } else if (_wrapped->ready() && _strip->inDefaultState(_index)) { + } else if (_wrapped->readyInDefaultState() + && _strip->inDefaultState(_index)) { _switched = true; _wrapped->paint(p, context); } else { @@ -91,6 +93,10 @@ bool StripEmoji::ready() { return _wrapped->ready(); } +bool StripEmoji::readyInDefaultState() { + return _wrapped->readyInDefaultState(); +} + } // namespace Selector::Selector( diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 3287bf45c..6dc630926 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 3287bf45c607e980268090ae27dfe4fb69d037e4 +Subproject commit 6dc6309269beb64a69e3184b671e030a2969f00e