From cb8418f840da1c91ae70fe027bb69c2f5dc76ba9 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 7 Jul 2023 18:29:22 +0300 Subject: [PATCH] Improve calls to on_update_user_has_stories. --- td/telegram/StoryManager.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index c458f0423..93a82e053 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -2338,16 +2338,11 @@ void StoryManager::on_update_active_stories(DialogId owner_dialog_id, StoryId ma LOG(INFO) << "Update active stories in " << owner_dialog_id << " to " << story_ids << " with max read " << max_read_story_id; - if (owner_dialog_id.get_type() == DialogType::User) { - if (story_ids.empty()) { - td_->contacts_manager_->on_update_user_has_stories(owner_dialog_id.get_user_id(), false, StoryId(), StoryId()); - } else { - td_->contacts_manager_->on_update_user_has_stories(owner_dialog_id.get_user_id(), true, story_ids.back(), - max_read_story_id); - } - } if (story_ids.empty()) { + if (owner_dialog_id.get_type() == DialogType::User) { + td_->contacts_manager_->on_update_user_has_stories(owner_dialog_id.get_user_id(), false, StoryId(), StoryId()); + } if (active_stories_.erase(owner_dialog_id) > 0) { LOG(INFO) << "Delete active stories for " << owner_dialog_id; send_update_chat_active_stories(owner_dialog_id); @@ -2372,6 +2367,10 @@ void StoryManager::on_update_active_stories(DialogId owner_dialog_id, StoryId ma } } } + if (owner_dialog_id.get_type() == DialogType::User) { + td_->contacts_manager_->on_update_user_has_stories(owner_dialog_id.get_user_id(), true, story_ids.back(), + max_read_story_id); + } if (active_stories->max_read_story_id_ != max_read_story_id || active_stories->story_ids_ != story_ids) { active_stories->max_read_story_id_ = max_read_story_id; active_stories->story_ids_ = std::move(story_ids);