From 53ea5b0fa14a952a3b59d775286d5c7b91481b34 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 11 Jul 2023 00:33:25 +0300 Subject: [PATCH] Add Story.is_being_edited. --- td/generate/scheme/td_api.tl | 3 ++- td/telegram/StoryManager.cpp | 14 ++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index a317db242..da5dc6378 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -4940,6 +4940,7 @@ storyInteractionInfo view_count:int32 recent_viewer_user_ids:vector = Sto //@id Unique story identifier among stories of the given sender //@sender_chat_id Identifier of the chat that posted the story //@date Point in time (Unix timestamp) when the story was published +//@is_being_edited True, if the story is being edited by the current user //@is_edited True, if the story was edited //@is_pinned True, if the story is saved in the sender's profile and will be available there after expiration //@is_visible_only_for_self True, if the story is visible only for the current user @@ -4951,7 +4952,7 @@ storyInteractionInfo view_count:int32 recent_viewer_user_ids:vector = Sto //@privacy_rules Privacy rules affecting story visibility; may be null if the story isn't owned //@content Content of the story //@caption Caption of the story -story id:int32 sender_chat_id:int53 date:int32 is_edited:Bool is_pinned:Bool is_visible_only_for_self:Bool can_be_forwarded:Bool can_be_replied:Bool can_get_viewers:Bool has_expired_viewers:Bool interaction_info:storyInteractionInfo privacy_rules:userPrivacySettingRules content:StoryContent caption:formattedText = Story; +story id:int32 sender_chat_id:int53 date:int32 is_being_edited:Bool is_edited:Bool is_pinned:Bool is_visible_only_for_self:Bool can_be_forwarded:Bool can_be_replied:Bool can_get_viewers:Bool has_expired_viewers:Bool interaction_info:storyInteractionInfo privacy_rules:userPrivacySettingRules content:StoryContent caption:formattedText = Story; //@description Represents a list of stories @total_count Approximate total number of stories found @stories The list of stories stories total_count:int32 stories:vector = Stories; diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index 9a21625a6..621527972 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -1974,6 +1974,7 @@ td_api::object_ptr StoryManager::get_story_object(StoryFullId sto privacy_rules = story->privacy_rules_.get_user_privacy_setting_rules_object(td_); } + bool is_being_edited = false; bool is_edited = story->is_edited_; auto story_id = story_full_id.get_story_id(); @@ -1988,7 +1989,7 @@ td_api::object_ptr StoryManager::get_story_object(StoryFullId sto if (it->second->edit_caption_) { caption = &it->second->caption_; } - is_edited = true; + is_being_edited = true; } } @@ -2006,9 +2007,9 @@ td_api::object_ptr StoryManager::get_story_object(StoryFullId sto return td_api::make_object( story_id.get(), td_->messages_manager_->get_chat_id_object(dialog_id, "get_story_object"), story->date_, - is_edited, story->is_pinned_, is_visible_only_for_self, can_be_forwarded, can_be_replied, can_get_viewers, - has_expired_viewers, story->interaction_info_.get_story_interaction_info_object(td_), std::move(privacy_rules), - get_story_content_object(td_, content), + is_being_edited, is_edited, story->is_pinned_, is_visible_only_for_self, can_be_forwarded, can_be_replied, + can_get_viewers, has_expired_viewers, story->interaction_info_.get_story_interaction_info_object(td_), + std::move(privacy_rules), get_story_content_object(td_, content), get_formatted_text_object(*caption, true, get_story_content_duration(td_, content))); } @@ -3218,16 +3219,13 @@ void StoryManager::delete_pending_story(FileId file_id, unique_ptr } CHECK(story->content_ != nullptr); auto promises = std::move(it->second->promises_); - bool is_changed = it->second->content_ != nullptr || - (it->second->edit_caption_ && it->second->caption_ != story->caption_) || - (status.is_error() && !story->is_edited_); auto log_event_id = it->second->log_event_id_; if (log_event_id != 0) { binlog_erase(G()->td_db()->get_binlog(), log_event_id); } being_edited_stories_.erase(it); - on_story_changed(story_full_id, story, is_changed, true); + on_story_changed(story_full_id, story, true, true); if (status.is_ok()) { set_promises(promises);