Support custom emoji in chats list entries.

This commit is contained in:
John Preston 2022-07-04 10:14:24 +04:00
parent ee8d8171f7
commit b976aa0872
5 changed files with 29 additions and 5 deletions

View file

@ -309,7 +309,7 @@ auto CustomEmojiLoader::InitialState(
if (!document->isNull()) { if (!document->isNull()) {
return Lookup{ document }; return Lookup{ document };
} }
return Resolve(); return Resolve{ .entityData = SerializeCustomEmojiId(id) };
} }
void CustomEmojiLoader::cancel() { void CustomEmojiLoader::cancel() {

View file

@ -406,6 +406,8 @@ void InnerWidget::changeOpenedFolder(Data::Folder *folder) {
void InnerWidget::paintEvent(QPaintEvent *e) { void InnerWidget::paintEvent(QPaintEvent *e) {
Painter p(this); Painter p(this);
p.setInactive(
_controller->isGifPausedAtLeastFor(Window::GifPauseReason::Any));
const auto r = e->rect(); const auto r = e->rect();
if (_controller->widget()->contentOverlapped(this, r)) { if (_controller->widget()->contentOverlapped(this, r)) {
return; return;

View file

@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/unread_badge.h" #include "ui/unread_badge.h"
#include "ui/ui_utility.h" #include "ui/ui_utility.h"
#include "core/ui_integration.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "support/support_helper.h" #include "support/support_helper.h"
#include "main/main_session.h" #include "main/main_session.h"
@ -455,6 +456,7 @@ void paintRow(
if (!ShowSendActionInDialogs(history) if (!ShowSendActionInDialogs(history)
|| !history->sendActionPainter()->paint(p, nameleft, texttop, availableWidth, fullWidth, color, ms)) { || !history->sendActionPainter()->paint(p, nameleft, texttop, availableWidth, fullWidth, color, ms)) {
if (history->cloudDraftTextCache.isEmpty()) { if (history->cloudDraftTextCache.isEmpty()) {
using namespace TextUtilities;
auto draftWrapped = Text::PlainLink( auto draftWrapped = Text::PlainLink(
tr::lng_dialogs_text_from_wrapped( tr::lng_dialogs_text_from_wrapped(
tr::now, tr::now,
@ -468,12 +470,23 @@ void paintRow(
lt_from_part, lt_from_part,
draftWrapped, draftWrapped,
lt_message, lt_message,
{ .text = draft->textWithTags.text }, {
.text = draft->textWithTags.text,
.entities = ConvertTextTagsToEntities(
draft->textWithTags.tags),
},
Text::WithEntities); Text::WithEntities);
const auto context = Core::MarkedTextContext{
.session = &history->session(),
.customEmojiRepaint = [=] {
history->updateChatListEntry();
},
};
history->cloudDraftTextCache.setMarkedText( history->cloudDraftTextCache.setMarkedText(
st::dialogsTextStyle, st::dialogsTextStyle,
draftText, draftText,
DialogTextOptions()); DialogTextOptions(),
context);
} }
p.setPen(active ? st::dialogsTextFgActive : (selected ? st::dialogsTextFgOver : st::dialogsTextFg)); p.setPen(active ? st::dialogsTextFgActive : (selected ? st::dialogsTextFgOver : st::dialogsTextFg));
if (supportMode) { if (supportMode) {

View file

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_options.h" #include "ui/text/text_options.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/image/image.h" #include "ui/image/image.h"
#include "core/ui_integration.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
@ -126,10 +127,18 @@ void MessageView::paint(
_senderCache = { st::dialogsTextWidthMin }; _senderCache = { st::dialogsTextWidthMin };
} }
TextUtilities::Trim(preview.text); TextUtilities::Trim(preview.text);
const auto history = item->history();
const auto context = Core::MarkedTextContext{
.session = &history->session(),
.customEmojiRepaint = [=] {
history->updateChatListEntry();
},
};
_textCache.setMarkedText( _textCache.setMarkedText(
st::dialogsTextStyle, st::dialogsTextStyle,
preview.text, preview.text,
DialogTextOptions()); DialogTextOptions(),
context);
_textCachedFor = item; _textCachedFor = item;
_imagesCache = std::move(preview.images); _imagesCache = std::move(preview.images);
if (preview.loadingContext.has_value()) { if (preview.loadingContext.has_value()) {

View file

@ -483,7 +483,7 @@ public:
private: private:
friend class HistoryBlock; friend class HistoryBlock;
enum class Flag { enum class Flag : uchar {
HasPendingResizedItems = (1 << 0), HasPendingResizedItems = (1 << 0),
UnreadThingsKnown = (1 << 1), UnreadThingsKnown = (1 << 1),
}; };