From b27a2cd34acd2643048ef269a600b3d293623d31 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 30 Aug 2019 18:00:32 +0300 Subject: [PATCH] Use edit_hide flag to hide 'edited' badge. --- .../history/history_item_components.cpp | 4 +++- Telegram/SourceFiles/history/history_message.h | 3 +++ .../history/view/history_view_message.cpp | 16 ++-------------- .../history/view/history_view_message.h | 1 - 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp index 26ffcf0e5..48610e6ba 100644 --- a/Telegram/SourceFiles/history/history_item_components.cpp +++ b/Telegram/SourceFiles/history/history_item_components.cpp @@ -80,7 +80,9 @@ int HistoryMessageSigned::maxWidth() const { } void HistoryMessageEdited::refresh(const QString &date, bool displayed) { - const auto prefix = displayed ? (tr::lng_edited(tr::now) + ' ') : QString(); + const auto prefix = displayed + ? (tr::lng_edited(tr::now) + ' ') + : QString(); text.setText(st::msgDateTextStyle, prefix + date, Ui::NameTextOptions()); } diff --git a/Telegram/SourceFiles/history/history_message.h b/Telegram/SourceFiles/history/history_message.h index d724723c0..c9904c160 100644 --- a/Telegram/SourceFiles/history/history_message.h +++ b/Telegram/SourceFiles/history/history_message.h @@ -118,6 +118,9 @@ public: [[nodiscard]] bool hasMessageBadge() const { return !_messageBadge.isEmpty(); } + [[nodiscard]] bool hideEditedBadge() const { + return (_flags & MTPDmessage::Flag::f_edit_hide); + } void applyGroupAdminChanges( const base::flat_set &changes) override; diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index aa0c29c89..9a294479b 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -1829,21 +1829,9 @@ bool Message::displayEditedBadge() const { TimeId Message::displayedEditDate() const { const auto item = message(); - auto hasViaBotId = item->Has(); - auto hasInlineMarkup = (item->inlineReplyMarkup() != nullptr); - return displayedEditDate(hasViaBotId || hasInlineMarkup); -} - -TimeId Message::displayedEditDate( - bool hasViaBotOrInlineMarkup) const { - if (hasViaBotOrInlineMarkup) { + if (item->hideEditedBadge()) { return TimeId(0); - } else if (const auto fromUser = message()->from()->asUser()) { - if (fromUser->isBot()) { - return TimeId(0); - } - } - if (const auto edited = displayedEditBadge()) { + } else if (const auto edited = displayedEditBadge()) { return edited->date; } return TimeId(0); diff --git a/Telegram/SourceFiles/history/view/history_view_message.h b/Telegram/SourceFiles/history/view/history_view_message.h index a7290ab7d..149b7db30 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.h +++ b/Telegram/SourceFiles/history/view/history_view_message.h @@ -142,7 +142,6 @@ private: bool displayFastShare() const; bool displayGoToOriginal() const; ClickHandlerPtr fastReplyLink() const; - TimeId displayedEditDate(bool hasViaBotOrInlineMarkup) const; const HistoryMessageEdited *displayedEditBadge() const; HistoryMessageEdited *displayedEditBadge(); void initTime();