Add reload_wallpaper method.

GitOrigin-RevId: 3750ae5bc58719da6d1715d00e4edb054bde12ed
This commit is contained in:
levlam 2019-01-18 14:33:23 +03:00
parent 2bb8a7549d
commit b275a77a84
2 changed files with 9 additions and 3 deletions

View File

@ -55,6 +55,10 @@ void WallpaperManager::get_wallpapers(Promise<Unit> &&promise) {
return promise.set_value(Unit());
}
reload_wallpapers(std::move(promise));
}
void WallpaperManager::reload_wallpapers(Promise<Unit> &&promise) {
pending_get_wallpapers_queries_.push_back(std::move(promise));
if (pending_get_wallpapers_queries_.size() == 1) {
auto request_promise = PromiseCreator::lambda(
@ -67,13 +71,13 @@ void WallpaperManager::get_wallpapers(Promise<Unit> &&promise) {
}
void WallpaperManager::on_get_wallpapers(Result<vector<telegram_api::object_ptr<telegram_api::WallPaper>>> result) {
CHECK(wallpapers_.empty());
auto promises = std::move(pending_get_wallpapers_queries_);
CHECK(!promises.empty());
reset_to_empty(pending_get_wallpapers_queries_);
if (result.is_error()) {
// do not clear wallpapers_
auto error = result.move_as_error();
for (auto &promise : promises) {
promise.set_error(error.clone());

View File

@ -22,7 +22,9 @@ class WallpaperManager : public Actor {
public:
WallpaperManager(Td *td, ActorShared<> parent);
void get_wallpapers(Promise<> &&promise);
void get_wallpapers(Promise<Unit> &&promise);
void reload_wallpapers(Promise<Unit> &&promise);
td_api::object_ptr<td_api::wallpapers> get_wallpapers_object() const;