Send updateStoryStealthMode when it changes.
This commit is contained in:
parent
8a41582fab
commit
5c1be5a1e7
@ -1095,6 +1095,11 @@ void StoryManager::start_up() {
|
||||
if (!stealth_mode_str.empty()) {
|
||||
log_event_parse(stealth_mode_, stealth_mode_str).ensure();
|
||||
stealth_mode_.update();
|
||||
if (stealth_mode_.is_empty()) {
|
||||
G()->td_db()->get_binlog_pmc()->erase(get_story_stealth_mode_key());
|
||||
} else {
|
||||
schedule_stealth_mode_update();
|
||||
}
|
||||
}
|
||||
send_update_story_stealth_mode();
|
||||
|
||||
@ -3424,6 +3429,19 @@ string StoryManager::get_story_stealth_mode_key() {
|
||||
return "stealth_mode";
|
||||
}
|
||||
|
||||
void StoryManager::schedule_stealth_mode_update() {
|
||||
if (stealth_mode_.is_empty()) {
|
||||
stealth_mode_update_timeout_.cancel_timeout();
|
||||
return;
|
||||
}
|
||||
|
||||
auto timeout = stealth_mode_.get_update_date() - G()->unix_time() + 2;
|
||||
LOG(INFO) << "Schedule stealth mode update in " << timeout;
|
||||
stealth_mode_update_timeout_.set_callback(std::move(update_stealth_mode_static));
|
||||
stealth_mode_update_timeout_.set_callback_data(static_cast<void *>(this));
|
||||
stealth_mode_update_timeout_.set_timeout_in(timeout);
|
||||
}
|
||||
|
||||
void StoryManager::set_story_stealth_mode(StoryStealthMode stealth_mode) {
|
||||
stealth_mode.update();
|
||||
if (stealth_mode == stealth_mode_) {
|
||||
@ -3431,6 +3449,7 @@ void StoryManager::set_story_stealth_mode(StoryStealthMode stealth_mode) {
|
||||
}
|
||||
|
||||
stealth_mode_ = stealth_mode;
|
||||
schedule_stealth_mode_update();
|
||||
send_update_story_stealth_mode();
|
||||
|
||||
if (stealth_mode_.is_empty()) {
|
||||
@ -3440,6 +3459,22 @@ void StoryManager::set_story_stealth_mode(StoryStealthMode stealth_mode) {
|
||||
}
|
||||
}
|
||||
|
||||
void StoryManager::update_stealth_mode_static(void *story_manager) {
|
||||
if (G()->close_flag()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK(story_manager != nullptr);
|
||||
static_cast<StoryManager *>(story_manager)->update_stealth_mode();
|
||||
}
|
||||
|
||||
void StoryManager::update_stealth_mode() {
|
||||
if (stealth_mode_.update()) {
|
||||
send_update_story_stealth_mode();
|
||||
}
|
||||
schedule_stealth_mode_update();
|
||||
}
|
||||
|
||||
DialogId StoryManager::get_changelog_story_dialog_id() const {
|
||||
return DialogId(UserId(td_->option_manager_->get_option_integer(
|
||||
"stories_changelog_user_id", ContactsManager::get_service_notifications_user_id().get())));
|
||||
|
@ -523,6 +523,12 @@ class StoryManager final : public Actor {
|
||||
|
||||
void send_update_story_stealth_mode() const;
|
||||
|
||||
void schedule_stealth_mode_update();
|
||||
|
||||
static void update_stealth_mode_static(void *story_manager);
|
||||
|
||||
void update_stealth_mode();
|
||||
|
||||
static string get_story_stealth_mode_key();
|
||||
|
||||
void set_story_stealth_mode(StoryStealthMode stealth_mode);
|
||||
@ -589,6 +595,8 @@ class StoryManager final : public Actor {
|
||||
|
||||
bool has_active_synchronize_archive_all_stories_query_ = false;
|
||||
|
||||
Timeout stealth_mode_update_timeout_;
|
||||
|
||||
Timeout interaction_info_update_timeout_;
|
||||
|
||||
int32 load_expired_database_stories_next_limit_ = DEFAULT_LOADED_EXPIRED_STORIES;
|
||||
|
Loading…
Reference in New Issue
Block a user