diff --git a/Telegram/SourceFiles/api/api_updates.cpp b/Telegram/SourceFiles/api/api_updates.cpp index 4b853a1e2d..f365ecce89 100644 --- a/Telegram/SourceFiles/api/api_updates.cpp +++ b/Telegram/SourceFiles/api/api_updates.cpp @@ -791,6 +791,10 @@ void Updates::mtpUpdateReceived(const MTPUpdates &updates) { } } +int32 Updates::pts() const { + return _ptsWaiter.current(); +} + void Updates::updateOnline() { updateOnline(false); } diff --git a/Telegram/SourceFiles/api/api_updates.h b/Telegram/SourceFiles/api/api_updates.h index 98bd13d603..b65744f510 100644 --- a/Telegram/SourceFiles/api/api_updates.h +++ b/Telegram/SourceFiles/api/api_updates.h @@ -33,6 +33,8 @@ public: void applyUpdatesNoPtsCheck(const MTPUpdates &updates); void applyUpdateNoPtsCheck(const MTPUpdate &update); + [[nodiscard]] int32 pts() const; + void updateOnline(); [[nodiscard]] bool isIdle() const; void checkIdleFinish(); diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index 91f7673fb7..59f165f477 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/media/history_view_media.h" // AddTimestampLinks. #include "chat_helpers/stickers_emoji_pack.h" #include "main/main_session.h" +#include "api/api_updates.h" #include "boxes/share_box.h" #include "boxes/confirm_box.h" #include "ui/toast/toast.h" @@ -1083,6 +1084,17 @@ void HistoryMessage::createComponents(const CreateConfig &config) { _fromNameVersion = from ? from->nameVersion : 1; } +bool HistoryMessage::checkRepliesPts(const MTPMessageReplies &data) const { + const auto channel = history()->peer->asChannel(); + const auto pts = channel + ? channel->pts() + : history()->session().updates().pts(); + const auto repliesPts = data.match([&](const MTPDmessageReplies &data) { + return data.vreplies_pts().v; + }); + return (repliesPts >= pts); +} + void HistoryMessage::setupForwardedComponent(const CreateConfig &config) { const auto forwarded = Get(); if (!forwarded) { @@ -1317,7 +1329,9 @@ void HistoryMessage::applyEdition(const MTPDmessage &message) { setForwardsCount(message.vforwards().value_or(-1)); setText(_media ? textWithEntities : EnsureNonEmpty(textWithEntities)); if (const auto replies = message.vreplies()) { - setReplies(*replies); + if (checkRepliesPts(*replies)) { + setReplies(*replies); + } } else { clearReplies(); } diff --git a/Telegram/SourceFiles/history/history_message.h b/Telegram/SourceFiles/history/history_message.h index 17d308ec9e..610b6044fd 100644 --- a/Telegram/SourceFiles/history/history_message.h +++ b/Telegram/SourceFiles/history/history_message.h @@ -236,6 +236,8 @@ private: const TextWithEntities &textWithEntities) const; void reapplyText(); + [[nodiscard]] bool checkRepliesPts(const MTPMessageReplies &data) const; + QString _timeText; int _timeWidth = 0;