From bfe2b8bc10df4324aa2ee2d3d9a6237d8448fbea Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 22 Apr 2026 10:21:54 +0300 Subject: [PATCH] Preserved caption text on cancel of send files box. --- Telegram/SourceFiles/boxes/send_files_box.cpp | 14 ++++++++++---- Telegram/SourceFiles/boxes/send_files_box.h | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index a7535d837d..362e48efce 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -819,7 +819,7 @@ void SendFilesBox::prepare() { setCloseByOutsideClick(false); boxClosing() | rpl::on_next([=] { - if (!_confirmed && _cancelledCallback) { + if (!_confirmed && !_textTaken && _cancelledCallback) { _cancelledCallback(); } }, lifetime()); @@ -2251,10 +2251,16 @@ rpl::producer SendFilesBox::takeTextWithTagsRequests() const { return _textWithTagsRequests.events(); } -void SendFilesBox::requestToTakeTextWithTags() const { - if (!_caption->isHidden()) { - _textWithTagsRequests.fire_copy(_caption->getTextWithTags()); +void SendFilesBox::requestToTakeTextWithTags() { + if (_caption->isHidden()) { + return; } + const auto text = _caption->getTextWithTags(); + if (!_prefilledCaptionText.text.isEmpty() && text.text.isEmpty()) { + return; + } + _textTaken = true; + _textWithTagsRequests.fire_copy(text); } void SendFilesBox::setInnerFocus() { diff --git a/Telegram/SourceFiles/boxes/send_files_box.h b/Telegram/SourceFiles/boxes/send_files_box.h index ca9e1d64fb..90f8a143a9 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.h +++ b/Telegram/SourceFiles/boxes/send_files_box.h @@ -270,7 +270,7 @@ private: void checkCharsLimitation(); void refreshMessagesCount(); - void requestToTakeTextWithTags() const; + void requestToTakeTextWithTags(); bool validateLength(const QString &text) const; [[nodiscard]] Fn prepareSendMenuDetails( @@ -303,6 +303,7 @@ private: std::unique_ptr _priceTag; QImage _priceTagBg; bool _confirmed = false; + bool _textTaken = false; bool _invertCaption = false; const object_ptr _caption;