From e6c4b96c54a06d45c6d9eb598974f176a01dad15 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 19 Sep 2021 17:36:29 +0300 Subject: [PATCH] Just close SendFilesBox on last item remove. Fixes https://bugs.telegram.org/c/2298 --- Telegram/SourceFiles/boxes/send_files_box.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index bd38c6701..66d32e0c7 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -549,9 +549,6 @@ void SendFilesBox::pushBlock(int from, int till) { block.takeWidget(), QMargins(0, _inner->count() ? st::sendMediaRowSkip : 0, 0, 0)); - const auto preventDelete = - widget->lifetime().make_state>(); - block.itemDeleteRequest( ) | rpl::filter([=] { return !_removingIndex; @@ -562,9 +559,9 @@ void SendFilesBox::pushBlock(int from, int till) { if (index < 0 || index >= _list.files.size()) { return; } - // Prevent item delete if it is the only one. + // Just close the box if it is the only one. if (_list.files.size() == 1) { - preventDelete->fire_copy(0); + closeBox(); return; } _list.files.erase(_list.files.begin() + index); @@ -572,9 +569,7 @@ void SendFilesBox::pushBlock(int from, int till) { }); }, widget->lifetime()); - rpl::merge( - block.itemReplaceRequest(), - preventDelete->events() + block.itemReplaceRequest( ) | rpl::start_with_next([=](int index) { const auto replace = [=](Ui::PreparedList list) { if (list.files.empty()) {