Animate emoji only twice in chats list.

This commit is contained in:
John Preston 2022-11-07 14:31:46 +04:00
parent 6e606f3bb6
commit 991fe491c5
3 changed files with 12 additions and 1 deletions

View file

@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/click_handler_types.h" #include "core/click_handler_types.h"
#include "data/stickers/data_custom_emoji.h" #include "data/stickers/data_custom_emoji.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "ui/text/text_custom_emoji.h"
#include "ui/basic_click_handlers.h" #include "ui/basic_click_handlers.h"
#include "ui/emoji_config.h" #include "ui/emoji_config.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
@ -249,9 +250,15 @@ std::unique_ptr<Ui::Text::CustomEmoji> UiIntegration::createCustomEmoji(
if (!my || !my->session) { if (!my || !my->session) {
return nullptr; return nullptr;
} }
return my->session->data().customEmojiManager().create( auto result = my->session->data().customEmojiManager().create(
data, data,
my->customEmojiRepaint); my->customEmojiRepaint);
if (my->customEmojiLoopLimit > 0) {
return std::make_unique<Ui::Text::LimitedLoopsEmoji>(
std::move(result),
my->customEmojiLoopLimit);
}
return result;
} }
Fn<void()> UiIntegration::createSpoilerRepaint(const std::any &context) { Fn<void()> UiIntegration::createSpoilerRepaint(const std::any &context) {

View file

@ -29,6 +29,7 @@ struct MarkedTextContext {
Main::Session *session = nullptr; Main::Session *session = nullptr;
HashtagMentionType type = HashtagMentionType::Telegram; HashtagMentionType type = HashtagMentionType::Telegram;
Fn<void()> customEmojiRepaint; Fn<void()> customEmojiRepaint;
int customEmojiLoopLimit = 0;
}; };
class UiIntegration final : public Ui::Integration { class UiIntegration final : public Ui::Integration {

View file

@ -23,6 +23,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace { namespace {
constexpr auto kEmojiLoopCount = 2;
template <ushort kTag> template <ushort kTag>
struct TextWithTagOffset { struct TextWithTagOffset {
TextWithTagOffset(TextWithEntities text) : text(std::move(text)) { TextWithTagOffset(TextWithEntities text) : text(std::move(text)) {
@ -142,6 +144,7 @@ void MessageView::prepare(
const auto context = Core::MarkedTextContext{ const auto context = Core::MarkedTextContext{
.session = &history->session(), .session = &history->session(),
.customEmojiRepaint = customEmojiRepaint, .customEmojiRepaint = customEmojiRepaint,
.customEmojiLoopLimit = kEmojiLoopCount,
}; };
const auto senderTill = (preview.arrowInTextPosition > 0) const auto senderTill = (preview.arrowInTextPosition > 0)
? preview.arrowInTextPosition ? preview.arrowInTextPosition