Skip to content

Commit

Permalink
f Migrate GIF search emoji sections to TDLib.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Oct 23, 2024
1 parent d6b0430 commit f4502fe
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
20 changes: 19 additions & 1 deletion Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ void EmojiPack::remove(not_null<const ViewElement*> view) {
}
}

#if 0 // mtp
auto EmojiPack::stickerForEmoji(EmojiPtr emoji) -> Sticker {
Expects(emoji != nullptr);

Expand All @@ -165,16 +164,35 @@ auto EmojiPack::stickerForEmoji(EmojiPtr emoji) -> Sticker {
return { i->second.get(), nullptr };
}
if (!emoji->colored()) {
request(emoji);
return {};
}
const auto j = _map.find(emoji->original());
if (j != end(_map)) {
const auto index = emoji->variantIndex(emoji);
return { j->second.get(), ColorReplacements(index) };
}
request(emoji->original());
return {};
}

void EmojiPack::request(EmojiPtr emoji) {
if (!_requested.emplace(emoji).second) {
return;
}
_session->sender().request(TLgetAnimatedEmoji(
tl_string(emoji->id())
)).done([=](const TLanimatedEmoji &result) {
const auto &data = result.data();
if (const auto &sticker = data.vsticker()) {
const auto document = _session->data().processDocument(*sticker);
_map.emplace(emoji, document);
_refreshed.fire({});
}
}).send();
}

#if 0 // mtp
auto EmojiPack::stickerForEmoji(const IsolatedEmoji &emoji) -> Sticker {
Expects(!emoji.empty());

Expand Down
9 changes: 5 additions & 4 deletions Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ class EmojiPack final {
bool add(not_null<ViewElement*> view);
void remove(not_null<const ViewElement*> view);

#if 0 // mtp
[[nodiscard]] Sticker stickerForEmoji(EmojiPtr emoji);
#if 0 // mtp
[[nodiscard]] Sticker stickerForEmoji(const IsolatedEmoji &emoji);
#endif
[[nodiscard]] std::shared_ptr<LargeEmojiImage> image(EmojiPtr emoji);
Expand All @@ -100,10 +100,10 @@ class EmojiPack final {
[[nodiscard]] int animationsVersion() const {
return _animationsVersion;
}
#endif
[[nodiscard]] rpl::producer<> refreshed() const {
return _refreshed.events();
}
#endif

[[nodiscard]] std::unique_ptr<Lottie::SinglePlayer> effectPlayer(
not_null<DocumentData*> document,
Expand Down Expand Up @@ -160,10 +160,11 @@ class EmojiPack final {
void refreshItems(const base::flat_set<not_null<ViewElement*>> &list);
void refreshItems(const base::flat_set<not_null<HistoryItem*>> &items);

void request(EmojiPtr emoji);
base::flat_set<EmojiPtr> _requested;

const not_null<Main::Session*> _session;
#if 0 // mtp
base::flat_map<EmojiPtr, not_null<DocumentData*>> _map;
#endif
base::flat_map<
IsolatedEmoji,
base::flat_set<not_null<HistoryView::Element*>>> _items;
Expand Down

0 comments on commit f4502fe

Please sign in to comment.