From fc878782b6cdc45113c0c82afbd2b5c3587fb85b Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 15 Jun 2023 13:49:23 +0300 Subject: [PATCH] Add StoryManager::get_active_stories. --- td/telegram/StoryManager.cpp | 10 +++++++--- td/telegram/StoryManager.h | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index 1774674e3..b6f11533e 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -525,6 +525,10 @@ StoryManager::Story *StoryManager::get_story_editable(StoryFullId story_full_id) return stories_.get_pointer(story_full_id); } +const StoryManager::ActiveStories *StoryManager::get_active_stories(DialogId owner_dialog_id) const { + return active_stories_.get_pointer(owner_dialog_id); +} + void StoryManager::toggle_dialog_stories_hidden(DialogId dialog_id, bool are_hidden, Promise &&promise) { if (!td_->messages_manager_->have_dialog_info_force(dialog_id)) { return promise.set_error(Status::Error(400, "Story sender not found")); @@ -836,7 +840,7 @@ td_api::object_ptr StoryManager::get_stories_object(int32 total } td_api::object_ptr StoryManager::get_active_stories_object(DialogId owner_dialog_id) const { - const auto *active_stories = active_stories_.get_pointer(owner_dialog_id); + const auto *active_stories = get_active_stories(owner_dialog_id); StoryId max_read_story_id; vector> stories; if (active_stories != nullptr) { @@ -1064,7 +1068,7 @@ void StoryManager::on_delete_story(DialogId owner_dialog_id, StoryId story_id) { delete_story_files(story); stories_.erase(story_full_id); - auto active_stories = active_stories_.get_pointer(owner_dialog_id); + auto active_stories = get_active_stories(owner_dialog_id); if (active_stories != nullptr && contains(active_stories->story_ids_, story_id)) { auto story_ids = active_stories->story_ids_; td::remove(story_ids, story_id); @@ -1242,7 +1246,7 @@ void StoryManager::send_update_active_stories(DialogId owner_dialog_id) { } void StoryManager::on_update_read_stories(DialogId owner_dialog_id, StoryId max_read_story_id) { - auto active_stories = active_stories_.get_pointer(owner_dialog_id); + auto active_stories = get_active_stories(owner_dialog_id); if (active_stories != nullptr && max_read_story_id.get() > active_stories->max_read_story_id_.get()) { auto story_ids = active_stories->story_ids_; on_update_active_stories(owner_dialog_id, max_read_story_id, std::move(story_ids)); diff --git a/td/telegram/StoryManager.h b/td/telegram/StoryManager.h index b30065b67..d013778ab 100644 --- a/td/telegram/StoryManager.h +++ b/td/telegram/StoryManager.h @@ -172,6 +172,8 @@ class StoryManager final : public Actor { Story *get_story_editable(StoryFullId story_full_id); + const ActiveStories *get_active_stories(DialogId owner_dialog_id) const; + void on_story_changed(StoryFullId story_full_id, const Story *story, bool is_changed, bool need_save_to_database); td_api::object_ptr get_story_info_object(StoryFullId story_full_id) const;