Pass promise to StickersManager::get_emoji_reaction.

This commit is contained in:
levlam 2022-11-03 21:07:07 +03:00
parent 2e3cc8619e
commit 82ab2da9c0
3 changed files with 12 additions and 4 deletions

View File

@ -1564,8 +1564,7 @@ void StickersManager::init() {
td_->option_manager_->set_option_empty("animated_emoji_sticker_set_name"); // legacy
}
td_api::object_ptr<td_api::emojiReaction> StickersManager::get_emoji_reaction_object(const string &emoji) {
load_reactions();
td_api::object_ptr<td_api::emojiReaction> StickersManager::get_emoji_reaction_object(const string &emoji) const {
for (auto &reaction : reactions_.reactions_) {
if (reaction.reaction_ == emoji) {
return td_api::make_object<td_api::emojiReaction>(
@ -1578,6 +1577,12 @@ td_api::object_ptr<td_api::emojiReaction> StickersManager::get_emoji_reaction_ob
return nullptr;
}
void StickersManager::get_emoji_reaction(const string &emoji,
Promise<td_api::object_ptr<td_api::emojiReaction>> &&promise) {
load_reactions();
promise.set_value(get_emoji_reaction_object(emoji));
}
vector<string> StickersManager::get_recent_reactions() {
load_recent_reactions();
return recent_reactions_.reactions_;

View File

@ -179,7 +179,7 @@ class StickersManager final : public Actor {
void view_featured_sticker_sets(const vector<StickerSetId> &sticker_set_ids);
td_api::object_ptr<td_api::emojiReaction> get_emoji_reaction_object(const string &emoji);
void get_emoji_reaction(const string &emoji, Promise<td_api::object_ptr<td_api::emojiReaction>> &&promise);
vector<string> get_recent_reactions();
@ -613,6 +613,8 @@ class StickersManager final : public Actor {
tl_object_ptr<td_api::stickerSetInfo> get_sticker_set_info_object(StickerSetId sticker_set_id, size_t covers_limit,
bool prefer_premium) const;
td_api::object_ptr<td_api::emojiReaction> get_emoji_reaction_object(const string &emoji) const;
Sticker *get_sticker(FileId file_id);
const Sticker *get_sticker(FileId file_id) const;

View File

@ -5233,7 +5233,8 @@ void Td::on_request(uint64 id, const td_api::getChatScheduledMessages &request)
void Td::on_request(uint64 id, const td_api::getEmojiReaction &request) {
CHECK_IS_USER();
send_closure(actor_id(this), &Td::send_result, id, stickers_manager_->get_emoji_reaction_object(request.emoji_));
CREATE_REQUEST_PROMISE();
stickers_manager_->get_emoji_reaction(request.emoji_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getCustomEmojiReactionAnimations &request) {