Just close SendFilesBox on last item remove.
Fixes https://bugs.telegram.org/c/2298
This commit is contained in:
parent
b75221737a
commit
e6c4b96c54
|
@ -549,9 +549,6 @@ void SendFilesBox::pushBlock(int from, int till) {
|
||||||
block.takeWidget(),
|
block.takeWidget(),
|
||||||
QMargins(0, _inner->count() ? st::sendMediaRowSkip : 0, 0, 0));
|
QMargins(0, _inner->count() ? st::sendMediaRowSkip : 0, 0, 0));
|
||||||
|
|
||||||
const auto preventDelete =
|
|
||||||
widget->lifetime().make_state<rpl::event_stream<int>>();
|
|
||||||
|
|
||||||
block.itemDeleteRequest(
|
block.itemDeleteRequest(
|
||||||
) | rpl::filter([=] {
|
) | rpl::filter([=] {
|
||||||
return !_removingIndex;
|
return !_removingIndex;
|
||||||
|
@ -562,9 +559,9 @@ void SendFilesBox::pushBlock(int from, int till) {
|
||||||
if (index < 0 || index >= _list.files.size()) {
|
if (index < 0 || index >= _list.files.size()) {
|
||||||
return;
|
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) {
|
if (_list.files.size() == 1) {
|
||||||
preventDelete->fire_copy(0);
|
closeBox();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_list.files.erase(_list.files.begin() + index);
|
_list.files.erase(_list.files.begin() + index);
|
||||||
|
@ -572,9 +569,7 @@ void SendFilesBox::pushBlock(int from, int till) {
|
||||||
});
|
});
|
||||||
}, widget->lifetime());
|
}, widget->lifetime());
|
||||||
|
|
||||||
rpl::merge(
|
block.itemReplaceRequest(
|
||||||
block.itemReplaceRequest(),
|
|
||||||
preventDelete->events()
|
|
||||||
) | rpl::start_with_next([=](int index) {
|
) | rpl::start_with_next([=](int index) {
|
||||||
const auto replace = [=](Ui::PreparedList list) {
|
const auto replace = [=](Ui::PreparedList list) {
|
||||||
if (list.files.empty()) {
|
if (list.files.empty()) {
|
||||||
|
|
Loading…
Reference in New Issue