Split opened stories by chats in StoryManager::update_interaction_info.

This commit is contained in:
levlam 2023-09-04 12:12:01 +03:00
parent 83d9f84c5b
commit d029d93f85

View File

@ -2371,16 +2371,18 @@ void StoryManager::update_interaction_info() {
if (opened_owned_stories_.empty()) {
return;
}
vector<StoryId> story_ids;
FlatHashMap<DialogId, vector<StoryId>, 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<GetStoriesViewsQuery>()->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<GetStoriesViewsQuery>()->send(std::move(story_ids.second));
}
}
void StoryManager::increment_story_views(DialogId owner_dialog_id, PendingStoryViews &story_views) {