From fa65e429eb9db47ea9a67af9b99b24938db86d1a Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 14 Sep 2021 10:16:20 +0300 Subject: [PATCH] Return void from RecentDialogList::load_dialogs. --- td/telegram/RecentDialogList.cpp | 16 +++++++--------- td/telegram/RecentDialogList.h | 3 ++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/td/telegram/RecentDialogList.cpp b/td/telegram/RecentDialogList.cpp index 163e941c2..5a552038d 100644 --- a/td/telegram/RecentDialogList.cpp +++ b/td/telegram/RecentDialogList.cpp @@ -21,6 +21,7 @@ namespace td { RecentDialogList::RecentDialogList(Td *td, const char *name, size_t max_size) : td_(td), name_(name), max_size_(max_size) { + register_actor(PSLICE() << name << "_chats", this).release(); } string RecentDialogList::get_binlog_key() const { @@ -68,10 +69,9 @@ void RecentDialogList::save_dialogs() const { G()->td_db()->get_binlog_pmc()->set(get_binlog_key(), result.str()); } -bool RecentDialogList::load_dialogs(Promise &&promise) { +void RecentDialogList::load_dialogs(Promise &&promise) { if (dialogs_loaded_ >= 2) { - promise.set_value(Unit()); - return true; + return promise.set_value(Unit()); } string found_dialogs_str = G()->td_db()->get_binlog_pmc()->get(get_binlog_key()); @@ -81,8 +81,7 @@ bool RecentDialogList::load_dialogs(Promise &&promise) { if (!dialog_ids_.empty()) { save_dialogs(); } - promise.set_value(Unit()); - return true; + return promise.set_value(Unit()); } auto found_dialogs = full_split(found_dialogs_str, ','); @@ -112,8 +111,7 @@ bool RecentDialogList::load_dialogs(Promise &&promise) { if (!newly_found_dialogs.empty()) { save_dialogs(); } - promise.set_value(Unit()); - return true; + return promise.set_value(Unit()); } resolve_dialogs_multipromise_.add_promise(std::move(promise)); @@ -146,7 +144,6 @@ bool RecentDialogList::load_dialogs(Promise &&promise) { lock.set_value(Unit()); } - return false; } void RecentDialogList::add_dialog(DialogId dialog_id) { @@ -233,7 +230,8 @@ void RecentDialogList::update_dialogs() { } std::pair> RecentDialogList::get_dialogs(int32 limit, Promise &&promise) { - if (!load_dialogs(std::move(promise))) { + load_dialogs(std::move(promise)); + if (dialogs_loaded_ != 2) { return {}; } diff --git a/td/telegram/RecentDialogList.h b/td/telegram/RecentDialogList.h index ac6c0bdaf..27698dbec 100644 --- a/td/telegram/RecentDialogList.h +++ b/td/telegram/RecentDialogList.h @@ -8,6 +8,7 @@ #include "td/telegram/DialogId.h" +#include "td/actor/actor.h" #include "td/actor/MultiPromise.h" #include "td/utils/common.h" @@ -42,7 +43,7 @@ class RecentDialogList : public Actor { int32 dialogs_loaded_ = 0; // 0 - not loaded, 1 - load request was sent, 2 - loaded MultiPromiseActor resolve_dialogs_multipromise_{"ResolveDialogsMultiPromiseActor"}; - bool load_dialogs(Promise &&promise); + void load_dialogs(Promise &&promise); bool do_add_dialog(DialogId dialog_id);