From fc98363d9564b167e1278b9ca041fae2f6f70538 Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 2 Sep 2023 23:23:38 +0300 Subject: [PATCH] Add StoryManager::on_update_dialog_has_pinned_stories/on_update_dialog_stories_hidden. --- td/telegram/StoryManager.cpp | 34 ++++++++++++++++++++++++++++++---- td/telegram/StoryManager.h | 4 ++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index 6bb0c5dd5..8eb0e5bd7 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -159,7 +159,7 @@ class ToggleStoriesHiddenQuery final : public Td::ResultHandler { auto result = result_ptr.move_as_ok(); LOG(DEBUG) << "Receive result for ToggleStoriesHiddenQuery: " << result; if (result) { - td_->contacts_manager_->on_update_user_stories_hidden(user_id_, are_hidden_); + td_->story_manager_->on_update_dialog_stories_hidden(DialogId(user_id_), are_hidden_); } promise_.set_value(Unit()); } @@ -1984,9 +1984,7 @@ void StoryManager::on_get_dialog_pinned_stories(DialogId owner_dialog_id, Promise> &&promise) { TRY_STATUS_PROMISE(promise, G()->close_status()); auto result = on_get_stories(owner_dialog_id, {}, std::move(stories)); - if (owner_dialog_id.get_type() == DialogType::User) { - td_->contacts_manager_->on_update_user_has_pinned_stories(owner_dialog_id.get_user_id(), result.first > 0); - } + on_update_dialog_has_pinned_stories(owner_dialog_id, result.first > 0); promise.set_value(get_stories_object(result.first, transform(result.second, [owner_dialog_id](StoryId story_id) { return StoryFullId(owner_dialog_id, story_id); }))); @@ -3346,6 +3344,34 @@ void StoryManager::on_update_dialog_max_read_story_id(DialogId owner_dialog_id, } } +void StoryManager::on_update_dialog_has_pinned_stories(DialogId owner_dialog_id, bool has_pinned_stories) { + switch (owner_dialog_id.get_type()) { + case DialogType::User: + td_->contacts_manager_->on_update_user_has_pinned_stories(owner_dialog_id.get_user_id(), has_pinned_stories); + break; + case DialogType::Chat: + case DialogType::Channel: + case DialogType::SecretChat: + case DialogType::None: + default: + break; + } +} + +void StoryManager::on_update_dialog_stories_hidden(DialogId owner_dialog_id, bool stories_hidden) { + switch (owner_dialog_id.get_type()) { + case DialogType::User: + td_->contacts_manager_->on_update_user_stories_hidden(owner_dialog_id.get_user_id(), stories_hidden); + break; + case DialogType::Chat: + case DialogType::Channel: + case DialogType::SecretChat: + case DialogType::None: + default: + break; + } +} + void StoryManager::on_update_active_stories(DialogId owner_dialog_id, StoryId max_read_story_id, vector &&story_ids, Promise &&promise, const char *source, bool from_database) { diff --git a/td/telegram/StoryManager.h b/td/telegram/StoryManager.h index 741daeaef..16f623c51 100644 --- a/td/telegram/StoryManager.h +++ b/td/telegram/StoryManager.h @@ -275,6 +275,8 @@ class StoryManager final : public Actor { void on_update_story_chosen_reaction_type(DialogId owner_dialog_id, StoryId story_id, ReactionType chosen_reaction_type); + void on_update_dialog_stories_hidden(DialogId owner_dialog_id, bool stories_hidden); + void on_dialog_active_stories_order_updated(DialogId owner_dialog_id, const char *source); Status can_get_story_viewers(StoryFullId story_full_id, const Story *story, bool ignore_premium) const; @@ -490,6 +492,8 @@ class StoryManager final : public Actor { void on_update_dialog_max_read_story_id(DialogId owner_dialog_id, StoryId max_read_story_id); + void on_update_dialog_has_pinned_stories(DialogId owner_dialog_id, bool has_pinned_stories); + void on_update_active_stories(DialogId owner_dialog_id, StoryId max_read_story_id, vector &&story_ids, Promise &&promise, const char *source, bool from_database = false);