Add is_owned_star_count_inited_.
This commit is contained in:
parent
f86cd1aaa0
commit
6c9f103264
@ -655,19 +655,23 @@ void StarManager::tear_down() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
td_api::object_ptr<td_api::updateOwnedStarCount> StarManager::get_update_owned_star_count_object() const {
|
td_api::object_ptr<td_api::updateOwnedStarCount> StarManager::get_update_owned_star_count_object() const {
|
||||||
|
CHECK(is_owned_star_count_inited_);
|
||||||
return td_api::make_object<td_api::updateOwnedStarCount>(owned_star_count_);
|
return td_api::make_object<td_api::updateOwnedStarCount>(owned_star_count_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StarManager::on_update_owned_star_count(int64 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;
|
return;
|
||||||
}
|
}
|
||||||
|
is_owned_star_count_inited_ = true;
|
||||||
owned_star_count_ = star_count;
|
owned_star_count_ = star_count;
|
||||||
send_closure(G()->td(), &Td::send_update, get_update_owned_star_count_object());
|
send_closure(G()->td(), &Td::send_update, get_update_owned_star_count_object());
|
||||||
}
|
}
|
||||||
|
|
||||||
void StarManager::add_owned_star_count(int64 star_count) {
|
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 {
|
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<td_api::object_ptr<td_api::Update>> &updates) const {
|
void StarManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
|
||||||
if (owned_star_count_ < (1ll << 62)) {
|
if (is_owned_star_count_inited_) {
|
||||||
updates.push_back(get_update_owned_star_count_object());
|
updates.push_back(get_update_owned_star_count_object());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,8 @@ class StarManager final : public Actor {
|
|||||||
Td *td_;
|
Td *td_;
|
||||||
ActorShared<> parent_;
|
ActorShared<> parent_;
|
||||||
|
|
||||||
int64 owned_star_count_ = (1ll << 62);
|
bool is_owned_star_count_inited_ = false;
|
||||||
|
int64 owned_star_count_ = 0;
|
||||||
|
|
||||||
FlatHashMap<DialogId, FlatHashMap<string, FileSourceId>, DialogIdHash> star_transaction_file_source_ids_[2];
|
FlatHashMap<DialogId, FlatHashMap<string, FileSourceId>, DialogIdHash> star_transaction_file_source_ids_[2];
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user