From 6c9f10326410274bccb66d51f07cfccdeca679b2 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 7 Aug 2024 16:37:00 +0300 Subject: [PATCH] Add is_owned_star_count_inited_. --- td/telegram/StarManager.cpp | 10 +++++++--- td/telegram/StarManager.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/td/telegram/StarManager.cpp b/td/telegram/StarManager.cpp index 466fcc94b..013687b13 100644 --- a/td/telegram/StarManager.cpp +++ b/td/telegram/StarManager.cpp @@ -655,19 +655,23 @@ void StarManager::tear_down() { } td_api::object_ptr StarManager::get_update_owned_star_count_object() const { + CHECK(is_owned_star_count_inited_); return td_api::make_object(owned_star_count_); } void StarManager::on_update_owned_star_count(int64 star_count) { - if (star_count == owned_star_count_) { + if (is_owned_star_count_inited_ && star_count == owned_star_count_) { return; } + is_owned_star_count_inited_ = true; owned_star_count_ = star_count; send_closure(G()->td(), &Td::send_update, get_update_owned_star_count_object()); } void StarManager::add_owned_star_count(int64 star_count) { - on_update_owned_star_count(star_count + owned_star_count_); + if (is_owned_star_count_inited_) { + on_update_owned_star_count(star_count + owned_star_count_); + } } Status StarManager::can_manage_stars(DialogId dialog_id, bool allow_self) const { @@ -873,7 +877,7 @@ int32 StarManager::get_months_by_star_count(int64 star_count) { } void StarManager::get_current_state(vector> &updates) const { - if (owned_star_count_ < (1ll << 62)) { + if (is_owned_star_count_inited_) { updates.push_back(get_update_owned_star_count_object()); } } diff --git a/td/telegram/StarManager.h b/td/telegram/StarManager.h index 267cb37c5..424102077 100644 --- a/td/telegram/StarManager.h +++ b/td/telegram/StarManager.h @@ -88,7 +88,8 @@ class StarManager final : public Actor { Td *td_; ActorShared<> parent_; - int64 owned_star_count_ = (1ll << 62); + bool is_owned_star_count_inited_ = false; + int64 owned_star_count_ = 0; FlatHashMap, DialogIdHash> star_transaction_file_source_ids_[2]; };