mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-01 12:00:48 +00:00
Sync custom emoji from strip to recent in the panel.
This commit is contained in:
parent
7c3814cdcd
commit
d5008fe7ac
@ -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<DocumentId> &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<Ui::Text::CustomEmoji*> 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<RecentEmojiDocument>(&data)) {
|
||||
return resolveCustomEmoji(document->id);
|
||||
return resolveCustomRecent(document->id);
|
||||
} else if (const auto emoji = std::get_if<EmojiPtr>(&data)) {
|
||||
return nullptr;
|
||||
}
|
||||
Unexpected("Custom recent emoji id.");
|
||||
}
|
||||
|
||||
not_null<Ui::Text::CustomEmoji*> EmojiListWidget::resolveCustomEmoji(
|
||||
not_null<Ui::Text::CustomEmoji*> 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 }
|
||||
|
@ -304,9 +304,9 @@ private:
|
||||
[[nodiscard]] not_null<Ui::Text::CustomEmoji*> resolveCustomEmoji(
|
||||
not_null<DocumentData*> document,
|
||||
uint64 setId);
|
||||
[[nodiscard]] Ui::Text::CustomEmoji *resolveCustomEmoji(
|
||||
[[nodiscard]] Ui::Text::CustomEmoji *resolveCustomRecent(
|
||||
Core::RecentEmojiId customId);
|
||||
[[nodiscard]] not_null<Ui::Text::CustomEmoji*> resolveCustomEmoji(
|
||||
[[nodiscard]] not_null<Ui::Text::CustomEmoji*> resolveCustomRecent(
|
||||
DocumentId documentId);
|
||||
[[nodiscard]] Fn<void()> repaintCallback(
|
||||
DocumentId documentId,
|
||||
@ -330,6 +330,9 @@ private:
|
||||
QVector<EmojiPtr> _emoji[kEmojiSectionCount];
|
||||
std::vector<CustomSet> _custom;
|
||||
base::flat_map<DocumentId, CustomEmojiInstance> _customEmoji;
|
||||
base::flat_map<
|
||||
DocumentId,
|
||||
std::unique_ptr<Ui::Text::CustomEmoji>> _customRecent;
|
||||
int _customSingleSize = 0;
|
||||
bool _allowWithoutPremium = false;
|
||||
Ui::RoundRect _overBg;
|
||||
|
@ -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<Ui::Text::CustomEmoji> _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(
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 3287bf45c607e980268090ae27dfe4fb69d037e4
|
||||
Subproject commit 6dc6309269beb64a69e3184b671e030a2969f00e
|
Loading…
Reference in New Issue
Block a user