Add updateStory.

This commit is contained in:
levlam 2023-06-01 13:55:11 +03:00
parent bf4694db65
commit 7bea5721bf
3 changed files with 10 additions and 2 deletions

View File

@ -5636,6 +5636,9 @@ updateUnreadMessageCount chat_list:ChatList unread_count:int32 unread_unmuted_co
//@marked_as_unread_unmuted_count Total number of unmuted chats marked as unread
updateUnreadChatCount chat_list:ChatList total_count:int32 unread_count:int32 unread_unmuted_count:int32 marked_as_unread_count:int32 marked_as_unread_unmuted_count:int32 = Update;
//@description A story was changed @story The new information about the story
updateStory story:story = Update;
//@description An option changed its value @name The option name @value The new option value
updateOption name:string value:OptionValue = Update;

View File

@ -458,6 +458,7 @@ td_api::object_ptr<td_api::story> StoryManager::get_story_object(StoryFullId sto
if (story == nullptr) {
return nullptr;
}
story->is_update_sent_ = true;
auto dialog_id = story_full_id.get_dialog_id();
bool is_owned = is_story_owned(dialog_id);
if (!is_owned && !story->is_pinned_ && G()->unix_time() >= story->expire_date_) {
@ -606,8 +607,9 @@ void StoryManager::on_story_changed(StoryFullId story_full_id, const Story *stor
if (is_changed || need_save_to_database) {
// save_story(story, story_id);
if (is_changed) {
// send_closure(G()->td(), &Td::send_update, td_api::make_object<td_api::updateStory>(get_story_object(story_full_id, story)));
if (is_changed && story->is_update_sent_) {
send_closure(G()->td(), &Td::send_update,
td_api::make_object<td_api::updateStory>(get_story_object(story_full_id, story)));
}
}
}
@ -863,6 +865,8 @@ void StoryManager::edit_story(StoryId story_id, td_api::object_ptr<td_api::Input
std::numeric_limits<uint32>::max() - (++send_story_count_),
story->edit_generation_, std::move(new_story));
on_story_changed(story_full_id, story, true, true);
if (edited_story->content_ == nullptr) {
return do_edit_story(FileId(), std::move(pending_story), nullptr);
}

View File

@ -37,6 +37,7 @@ class StoryManager final : public Actor {
bool is_pinned_ = false;
bool is_public_ = false;
bool is_for_close_friends_ = false;
mutable bool is_update_sent_ = false; // whether the story is known to the app
StoryInteractionInfo interaction_info_;
UserPrivacySettingRules privacy_rules_;
unique_ptr<StoryContent> content_;