Simplify update_story_list_sent_total_count usage.

This commit is contained in:
levlam 2023-07-13 15:37:11 +03:00
parent 39eb3fdb0d
commit 39b0b53ae9
2 changed files with 9 additions and 6 deletions

View File

@ -1278,6 +1278,10 @@ td_api::object_ptr<td_api::updateStoryListChatCount> StoryManager::get_update_st
story_list.sent_total_count_);
}
void StoryManager::update_story_list_sent_total_count(StoryListId story_list_id) {
update_story_list_sent_total_count(story_list_id, story_lists_[story_list_id == StoryListId::archive()]);
}
void StoryManager::update_story_list_sent_total_count(StoryListId story_list_id, StoryList &story_list) {
if (story_list.list_last_story_date_ == MIN_DIALOG_DATE || story_list.server_total_count_ == -1) {
return;
@ -2538,8 +2542,7 @@ void StoryManager::on_update_active_stories(DialogId owner_dialog_id, StoryId ma
LOG(INFO) << "Delete active stories for " << owner_dialog_id;
if (active_stories->story_list_id_.is_valid()) {
delete_active_stories_from_story_list(owner_dialog_id, active_stories);
update_story_list_sent_total_count(active_stories->story_list_id_,
story_lists_[active_stories->story_list_id_ == StoryListId::archive()]);
update_story_list_sent_total_count(active_stories->story_list_id_);
}
active_stories_.erase(owner_dialog_id);
send_update_chat_active_stories(owner_dialog_id);
@ -2622,15 +2625,13 @@ bool StoryManager::update_active_stories_order(DialogId owner_dialog_id, ActiveS
CHECK(is_inserted);
if (active_stories->story_list_id_ != story_list_id) {
update_story_list_sent_total_count(active_stories->story_list_id_,
story_lists_[active_stories->story_list_id_ == StoryListId::archive()]);
update_story_list_sent_total_count(active_stories->story_list_id_);
}
update_story_list_sent_total_count(story_list_id, story_list);
}
} else if (active_stories->story_list_id_.is_valid()) {
delete_active_stories_from_story_list(owner_dialog_id, active_stories);
update_story_list_sent_total_count(active_stories->story_list_id_,
story_lists_[active_stories->story_list_id_ == StoryListId::archive()]);
update_story_list_sent_total_count(active_stories->story_list_id_);
}
if (active_stories->private_order_ != new_private_order || active_stories->public_order_ != new_public_order ||

View File

@ -360,6 +360,8 @@ class StoryManager final : public Actor {
td_api::object_ptr<td_api::updateStoryListChatCount> get_update_story_list_chat_count_object(
StoryListId story_list_id, const StoryList &story_list) const;
void update_story_list_sent_total_count(StoryListId story_list_id);
void update_story_list_sent_total_count(StoryListId story_list_id, StoryList &story_list);
vector<FileId> get_story_file_ids(const Story *story) const;