Fixed crash on restricting users from moderation box.

This commit is contained in:
23rd 2024-05-04 13:32:07 +03:00 committed by John Preston
parent 129d356909
commit a866ba8cdd

View file

@ -678,15 +678,20 @@ void CreateModerateMessagesBox(
Ui::AddSkip(container); Ui::AddSkip(container);
container->add(std::move(checkboxes)); container->add(std::move(checkboxes));
handleConfirmation(ban, controller, [=]( // Handle confirmation manually.
confirms->events() | rpl::start_with_next([=] {
if (ban->checked() && controller->collectRequests) {
const auto kick = !wrap->toggled();
const auto restrictions = getRestrictions();
const auto request = [=](
not_null<PeerData*> peer, not_null<PeerData*> peer,
not_null<ChannelData*> channel) { not_null<ChannelData*> channel) {
if (wrap->toggled()) { if (!kick) {
Api::ChatParticipants::Restrict( Api::ChatParticipants::Restrict(
channel, channel,
peer, peer,
ChatRestrictionsInfo(), // Unused. ChatRestrictionsInfo(), // Unused.
ChatRestrictionsInfo(getRestrictions(), 0), ChatRestrictionsInfo(restrictions, 0),
nullptr, nullptr,
nullptr); nullptr);
} else { } else {
@ -695,7 +700,10 @@ void CreateModerateMessagesBox(
peer, peer,
{ channel->restrictions(), 0 }); { channel->restrictions(), 0 });
} }
}); };
sequentiallyRequest(request, controller->collectRequests());
}
}, ban->lifetime());
} }
const auto close = crl::guard(box, [=] { box->closeBox(); }); const auto close = crl::guard(box, [=] { box->closeBox(); });