mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-23 16:56:55 +00:00
Added to moderate box number of all messages that will be deleted.
This commit is contained in:
parent
b8b02b2285
commit
be255f1d09
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "boxes/moderate_messages_box.h"
|
||||
|
||||
#include "api/api_chat_participants.h"
|
||||
#include "api/api_messages_search.h"
|
||||
#include "apiwrap.h"
|
||||
#include "base/event_filter.h"
|
||||
#include "base/timer.h"
|
||||
@ -82,6 +83,24 @@ ModerateOptions CalculateModerateOptions(const HistoryItemsList &items) {
|
||||
return result;
|
||||
}
|
||||
|
||||
[[nodiscard]] rpl::producer<int> MessagesCountValue(
|
||||
not_null<History*> history,
|
||||
not_null<PeerData*> from) {
|
||||
return [=](auto consumer) {
|
||||
auto lifetime = rpl::lifetime();
|
||||
auto search = lifetime.make_state<Api::MessagesSearch>(history);
|
||||
consumer.put_next(0);
|
||||
|
||||
search->messagesFounds(
|
||||
) | rpl::start_with_next([=](const Api::FoundMessages &found) {
|
||||
consumer.put_next_copy(found.total);
|
||||
}, lifetime);
|
||||
search->searchMessages({ .from = from });
|
||||
|
||||
return lifetime;
|
||||
};
|
||||
}
|
||||
|
||||
class Button final : public Ui::RippleButton {
|
||||
public:
|
||||
Button(not_null<QWidget*> parent, int count);
|
||||
@ -411,7 +430,7 @@ void CreateModerateMessagesBox(
|
||||
};
|
||||
|
||||
Ui::AddSkip(inner);
|
||||
box->addRow(
|
||||
const auto title = box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
(items.size() == 1)
|
||||
@ -475,6 +494,22 @@ void CreateModerateMessagesBox(
|
||||
false,
|
||||
st::defaultBoxCheckbox),
|
||||
st::boxRowPadding + buttonPadding);
|
||||
if (isSingle) {
|
||||
const auto history = items.front()->history();
|
||||
tr::lng_selected_delete_sure(
|
||||
lt_count,
|
||||
rpl::combine(
|
||||
MessagesCountValue(history, users.front()),
|
||||
deleteAll->checkedValue()
|
||||
) | rpl::map([s = items.size()](int all, bool checked) {
|
||||
return float64((checked && all) ? all : s);
|
||||
})
|
||||
) | rpl::start_with_next([=](const QString &text) {
|
||||
title->setText(text);
|
||||
title->resizeToWidth(inner->width()
|
||||
- rect::m::sum::h(st::boxRowPadding));
|
||||
}, title->lifetime());
|
||||
}
|
||||
|
||||
const auto controller = box->lifetime().make_state<Controller>();
|
||||
appendList(deleteAll, controller);
|
||||
|
Loading…
Reference in New Issue
Block a user