mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fixed possible crash in moderate box.
This commit is contained in:
parent
7e071c770f
commit
ad6321d3ae
1 changed files with 16 additions and 14 deletions
|
@ -227,12 +227,12 @@ void CreateModerateMessagesBox(
|
||||||
? QMargins()
|
? QMargins()
|
||||||
: QMargins(0, 0, Button::ComputeSize(users.size()).width(), 0);
|
: QMargins(0, 0, Button::ComputeSize(users.size()).width(), 0);
|
||||||
|
|
||||||
|
const auto session = &items.front()->history()->session();
|
||||||
|
const auto historyPeerId = items.front()->history()->peer->id;
|
||||||
|
|
||||||
using Request = Fn<void(not_null<UserData*>, not_null<ChannelData*>)>;
|
using Request = Fn<void(not_null<UserData*>, not_null<ChannelData*>)>;
|
||||||
const auto sequentiallyRequest = [=](Request request, Users users) {
|
const auto sequentiallyRequest = [=](Request request, Users users) {
|
||||||
constexpr auto kSmallDelayMs = 5;
|
constexpr auto kSmallDelayMs = 5;
|
||||||
const auto session = &items.front()->history()->session();
|
|
||||||
const auto history = items.front()->history();
|
|
||||||
const auto peerId = history->peer->id;
|
|
||||||
const auto userIds = ranges::views::all(
|
const auto userIds = ranges::views::all(
|
||||||
users
|
users
|
||||||
) | ranges::views::transform([](not_null<UserData*> user) {
|
) | ranges::views::transform([](not_null<UserData*> user) {
|
||||||
|
@ -243,7 +243,7 @@ void CreateModerateMessagesBox(
|
||||||
const auto timer = lifetime->make_state<base::Timer>();
|
const auto timer = lifetime->make_state<base::Timer>();
|
||||||
timer->setCallback(crl::guard(session, [=] {
|
timer->setCallback(crl::guard(session, [=] {
|
||||||
if ((*counter) < userIds.size()) {
|
if ((*counter) < userIds.size()) {
|
||||||
const auto peer = session->data().peer(peerId);
|
const auto peer = session->data().peer(historyPeerId);
|
||||||
const auto channel = peer ? peer->asChannel() : nullptr;
|
const auto channel = peer ? peer->asChannel() : nullptr;
|
||||||
const auto from = session->data().peer(userIds[*counter]);
|
const auto from = session->data().peer(userIds[*counter]);
|
||||||
if (const auto user = from->asUser(); channel && user) {
|
if (const auto user = from->asUser(); channel && user) {
|
||||||
|
@ -697,17 +697,19 @@ void CreateModerateMessagesBox(
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto close = crl::guard(box, [=] { box->closeBox(); });
|
const auto close = crl::guard(box, [=] { box->closeBox(); });
|
||||||
box->addButton(tr::lng_box_delete(), [=] {
|
{
|
||||||
confirms->fire({});
|
|
||||||
const auto data = &users.front()->session().data();
|
const auto data = &users.front()->session().data();
|
||||||
const auto ids = data->itemsToIds(items);
|
const auto ids = users.front()->session().data().itemsToIds(items);
|
||||||
if (confirmed) {
|
box->addButton(tr::lng_box_delete(), [=] {
|
||||||
confirmed();
|
confirms->fire({});
|
||||||
}
|
if (confirmed) {
|
||||||
data->histories().deleteMessages(ids, true);
|
confirmed();
|
||||||
data->sendHistoryChangeNotifications();
|
}
|
||||||
close();
|
data->histories().deleteMessages(ids, true);
|
||||||
});
|
data->sendHistoryChangeNotifications();
|
||||||
|
close();
|
||||||
|
});
|
||||||
|
}
|
||||||
box->addButton(tr::lng_cancel(), close);
|
box->addButton(tr::lng_cancel(), close);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue