From ee1162faff799d79884a7097ab34061d40c941dc Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 8 Feb 2023 15:48:05 +0400 Subject: [PATCH] Version 4.6.2: Fix ghost drafts appearing in channels. --- Telegram/SourceFiles/history/history_widget.cpp | 11 +++++++---- Telegram/SourceFiles/history/history_widget.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 7b33b4538..975517ce2 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1867,11 +1867,11 @@ void HistoryWidget::fastShowAtEnd(not_null history) { } } -void HistoryWidget::applyDraft(FieldHistoryAction fieldHistoryAction) { +bool HistoryWidget::applyDraft(FieldHistoryAction fieldHistoryAction) { InvokeQueued(this, [=] { updateStickersByEmoji(); }); if (_voiceRecordBar->isActive() || !_canSendTexts) { - return; + return false; } const auto editDraft = _history ? _history->localEditDraft({}) : nullptr; @@ -1893,7 +1893,7 @@ void HistoryWidget::applyDraft(FieldHistoryAction fieldHistoryAction) { updateControlsGeometry(); } refreshTopBarActiveChat(); - return; + return true; } _textUpdateEvents = 0; @@ -1930,6 +1930,7 @@ void HistoryWidget::applyDraft(FieldHistoryAction fieldHistoryAction) { _processingReplyId = draft ? draft->msgId : MsgId(); processReply(); } + return true; } void HistoryWidget::applyCloudDraft(History *history) { @@ -2261,7 +2262,9 @@ void HistoryWidget::showHistory( handlePeerUpdate(); session().local().readDraftsWithCursors(_history); - applyDraft(); + if (!applyDraft()) { + clearFieldText(); + } _send->finishAnimating(); updateControlsGeometry(); diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 5533ca0cc..93683a8e2 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -213,7 +213,7 @@ public: void botCallbackSent(not_null item); void fastShowAtEnd(not_null history); - void applyDraft( + bool applyDraft( FieldHistoryAction fieldHistoryAction = FieldHistoryAction::Clear); void showHistory(const PeerId &peer, MsgId showAtMsgId, bool reload = false); void setChooseReportMessagesDetails(