Automatically load installed sticker sets in StickersManager::get_stickers.

This commit is contained in:
levlam 2022-08-06 23:39:54 +03:00
parent 035cec9fb9
commit 1764cda9fa
2 changed files with 19 additions and 2 deletions

View File

@ -3814,13 +3814,30 @@ std::pair<vector<FileId>, vector<FileId>> StickersManager::split_stickers_by_pre
vector<FileId> StickersManager::get_stickers(StickerType sticker_type, string emoji, int32 limit, DialogId dialog_id,
bool force, Promise<Unit> &&promise) {
if (G()->close_flag()) {
promise.set_error(G()->close_status());
return {};
}
if (limit <= 0) {
promise.set_error(Status::Error(400, "Parameter limit must be positive"));
return {};
}
auto type = static_cast<int32>(sticker_type);
if (!are_installed_sticker_sets_loaded_[type]) {
load_installed_sticker_sets(sticker_type, std::move(promise));
CHECK(force == false);
load_installed_sticker_sets(
sticker_type,
PromiseCreator::lambda([actor_id = actor_id(this), sticker_type, emoji = std::move(emoji), limit, dialog_id,
force, promise = std::move(promise)](Result<Unit> result) mutable {
if (result.is_error()) {
promise.set_error(result.move_as_error());
} else {
send_closure(actor_id, &StickersManager::get_stickers, sticker_type, std::move(emoji), limit, dialog_id,
false, std::move(promise));
}
}));
return {};
}

View File

@ -2007,7 +2007,7 @@ class GetStickersRequest final : public RequestActor<> {
, emoji_(std::move(emoji))
, limit_(limit)
, dialog_id_(dialog_id) {
set_tries(5);
set_tries(4);
}
};