Save owned star count between restarts.
This commit is contained in:
parent
86afb5b0f3
commit
52f24d72f5
@ -26,6 +26,7 @@
|
|||||||
#include "td/telegram/StatisticsManager.h"
|
#include "td/telegram/StatisticsManager.h"
|
||||||
#include "td/telegram/StickersManager.h"
|
#include "td/telegram/StickersManager.h"
|
||||||
#include "td/telegram/Td.h"
|
#include "td/telegram/Td.h"
|
||||||
|
#include "td/telegram/TdDb.h"
|
||||||
#include "td/telegram/telegram_api.h"
|
#include "td/telegram/telegram_api.h"
|
||||||
#include "td/telegram/UpdatesManager.h"
|
#include "td/telegram/UpdatesManager.h"
|
||||||
#include "td/telegram/UserManager.h"
|
#include "td/telegram/UserManager.h"
|
||||||
@ -670,6 +671,15 @@ class GetStarsRevenueAdsAccountUrlQuery final : public Td::ResultHandler {
|
|||||||
StarManager::StarManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
|
StarManager::StarManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StarManager::start_up() {
|
||||||
|
auto owned_star_count = G()->td_db()->get_binlog_pmc()->get("owned_star_count");
|
||||||
|
if (!owned_star_count.empty()) {
|
||||||
|
is_owned_star_count_inited_ = true;
|
||||||
|
owned_star_count_ = to_integer<int64>(owned_star_count);
|
||||||
|
send_closure(G()->td(), &Td::send_update, get_update_owned_star_count_object());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void StarManager::tear_down() {
|
void StarManager::tear_down() {
|
||||||
parent_.reset();
|
parent_.reset();
|
||||||
}
|
}
|
||||||
@ -686,6 +696,7 @@ void StarManager::on_update_owned_star_count(int64 star_count) {
|
|||||||
is_owned_star_count_inited_ = true;
|
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());
|
||||||
|
G()->td_db()->get_binlog_pmc()->set("owned_star_count", to_string(owned_star_count_));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StarManager::add_owned_star_count(int64 star_count) {
|
void StarManager::add_owned_star_count(int64 star_count) {
|
||||||
|
@ -73,6 +73,8 @@ class StarManager final : public Actor {
|
|||||||
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void start_up() final;
|
||||||
|
|
||||||
void tear_down() final;
|
void tear_down() final;
|
||||||
|
|
||||||
Status can_manage_stars(DialogId dialog_id, bool allow_self = false) const;
|
Status can_manage_stars(DialogId dialog_id, bool allow_self = false) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user