From 46d3f232af1721c7f9cc76e2e5b22a3b11fbc3d7 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 31 Oct 2023 13:08:32 +0400 Subject: [PATCH] Don't drop reply info on empty message submit. --- Telegram/SourceFiles/history/history_widget.cpp | 9 ++++++++- Telegram/SourceFiles/history/history_widget.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 289438e5b..b0e5f8d2a 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -842,7 +842,9 @@ HistoryWidget::HistoryWidget( }); } else { fastShowAtEnd(action.history); - if (cancelReply(lastKeyboardUsed) && !action.clearDraft) { + if (!_justMarkingAsRead + && cancelReply(lastKeyboardUsed) + && !action.clearDraft) { saveCloudDraft(); } } @@ -3963,7 +3965,12 @@ void HistoryWidget::send(Api::SendOptions options) { ignoreSlowmodeCountdown)) { return; } + + // Just a flag not to drop reply info if we're not sending anything. + _justMarkingAsRead = !HasSendText(_field) + && message.webPage.url.isEmpty(); session().api().sendMessage(std::move(message)); + _justMarkingAsRead = false; clearFieldText(); if (_preview) { diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 450985010..ebc1a04c8 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -812,6 +812,7 @@ private: int _itemsRevealHeight = 0; bool _sponsoredMessagesStateKnown = false; + bool _justMarkingAsRead = false; object_ptr _topShadow; bool _inGrab = false;