From d029d93f85c715986fa3110f7dd2cd319ed3042d Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 4 Sep 2023 12:12:01 +0300 Subject: [PATCH] Split opened stories by chats in StoryManager::update_interaction_info. --- td/telegram/StoryManager.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index 8eb0e5bd7..76e0deea9 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -2371,16 +2371,18 @@ void StoryManager::update_interaction_info() { if (opened_owned_stories_.empty()) { return; } - vector story_ids; + FlatHashMap, DialogIdHash> splitted_story_ids; for (auto &it : opened_owned_stories_) { auto story_full_id = it.first; - CHECK(story_full_id.get_dialog_id() == DialogId(td_->contacts_manager_->get_my_id())); - story_ids.push_back(story_full_id.get_story_id()); - if (story_ids.size() >= 100) { - break; + auto &story_ids = splitted_story_ids[story_full_id.get_dialog_id()]; + if (story_ids.size() < 100) { + story_ids.push_back(story_full_id.get_story_id()); } } - td_->create_handler()->send(std::move(story_ids)); + for (auto &story_ids : splitted_story_ids) { + CHECK(story_ids.first == DialogId(td_->contacts_manager_->get_my_id())); + td_->create_handler()->send(std::move(story_ids.second)); + } } void StoryManager::increment_story_views(DialogId owner_dialog_id, PendingStoryViews &story_views) {