From 46a76fa9a8bd4200f95807ebdcbcf3614c6d4961 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 27 Mar 2023 00:54:44 +0300 Subject: [PATCH] Add CustomEmojiId::get_custom_emoji_ids. --- td/telegram/CustomEmojiId.h | 9 +++++++++ td/telegram/StickersManager.cpp | 13 +++++-------- td/telegram/Td.cpp | 5 ++--- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/td/telegram/CustomEmojiId.h b/td/telegram/CustomEmojiId.h index aa303b25d..93f466832 100644 --- a/td/telegram/CustomEmojiId.h +++ b/td/telegram/CustomEmojiId.h @@ -41,6 +41,15 @@ class CustomEmojiId { return id != other.id; } + static vector get_custom_emoji_ids(const vector &document_ids) { + vector custom_emoji_ids; + custom_emoji_ids.reserve(document_ids.size()); + for (auto &document_id : document_ids) { + custom_emoji_ids.emplace_back(document_id); + } + return custom_emoji_ids; + } + template void store(StorerT &storer) const { storer.store_long(id); diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 40bfbc288..40d6afaf8 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -5101,13 +5101,11 @@ void StickersManager::on_find_custom_emojis_success(const string &emoji, case telegram_api::emojiList::ID: { auto emoji_list = move_tl_object_as(stickers); - auto custom_emoji_ids = - transform(std::move(emoji_list->document_id_), [](int64 document_id) { return CustomEmojiId(document_id); }); - auto hash = emoji_list->hash_; - + auto custom_emoji_ids = CustomEmojiId::get_custom_emoji_ids(emoji_list->document_id_); get_custom_emoji_stickers_unlimited( - custom_emoji_ids, PromiseCreator::lambda([actor_id = actor_id(this), emoji, hash, custom_emoji_ids]( - Result> &&result) { + custom_emoji_ids, + PromiseCreator::lambda([actor_id = actor_id(this), emoji, hash = emoji_list->hash_, + custom_emoji_ids](Result> &&result) { send_closure(actor_id, &StickersManager::on_load_custom_emojis, std::move(emoji), hash, custom_emoji_ids, std::move(result)); })); @@ -6801,8 +6799,7 @@ void StickersManager::on_get_default_dialog_photo_custom_emoji_ids( } CHECK(constructor_id == telegram_api::emojiList::ID); auto emoji_list = move_tl_object_as(emoji_list_ptr); - auto custom_emoji_ids = - transform(std::move(emoji_list->document_id_), [](int64 document_id) { return CustomEmojiId(document_id); }); + auto custom_emoji_ids = CustomEmojiId::get_custom_emoji_ids(emoji_list->document_id_); auto hash = emoji_list->hash_; if (G()->use_sqlite_pmc()) { diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 2e7a66595..9d63b3018 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -7461,9 +7461,8 @@ void Td::on_request(uint64 id, td_api::getEmojiSuggestionsUrl &request) { void Td::on_request(uint64 id, const td_api::getCustomEmojiStickers &request) { CREATE_REQUEST_PROMISE(); - stickers_manager_->get_custom_emoji_stickers( - transform(request.custom_emoji_ids_, [](int64 custom_emoji_id) { return CustomEmojiId(custom_emoji_id); }), true, - std::move(promise)); + stickers_manager_->get_custom_emoji_stickers(CustomEmojiId::get_custom_emoji_ids(request.custom_emoji_ids_), true, + std::move(promise)); } void Td::on_request(uint64 id, const td_api::getDefaultChatPhotoCustomEmojiStickers &request) {