Add CustomEmojiId::get_custom_emoji_ids.

This commit is contained in:
levlam 2023-03-27 00:54:44 +03:00
parent 881e74accb
commit 46a76fa9a8
3 changed files with 16 additions and 11 deletions

View File

@ -41,6 +41,15 @@ class CustomEmojiId {
return id != other.id;
}
static vector<CustomEmojiId> get_custom_emoji_ids(const vector<int64> &document_ids) {
vector<CustomEmojiId> 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 <class StorerT>
void store(StorerT &storer) const {
storer.store_long(id);

View File

@ -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<telegram_api::emojiList>(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<td_api::object_ptr<td_api::stickers>> &&result) {
custom_emoji_ids,
PromiseCreator::lambda([actor_id = actor_id(this), emoji, hash = emoji_list->hash_,
custom_emoji_ids](Result<td_api::object_ptr<td_api::stickers>> &&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<telegram_api::emojiList>(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()) {

View File

@ -7461,8 +7461,7 @@ 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,
stickers_manager_->get_custom_emoji_stickers(CustomEmojiId::get_custom_emoji_ids(request.custom_emoji_ids_), true,
std::move(promise));
}