mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-27 16:03:03 +02:00
parent
01e313e56b
commit
e62881e08b
1 changed files with 144 additions and 127 deletions
|
@ -361,9 +361,14 @@ void CreateModerateMessagesBox(
|
|||
});
|
||||
}
|
||||
if (allCanBan) {
|
||||
auto ownedWrap = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
const auto peer = items.front()->history()->peer;
|
||||
auto ownedWrap = peer->isMonoforum()
|
||||
? nullptr
|
||||
: object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
inner,
|
||||
object_ptr<Ui::VerticalLayout>(inner));
|
||||
auto computeRestrictions = Fn<ChatRestrictions()>();
|
||||
const auto wrap = ownedWrap.data();
|
||||
|
||||
Ui::AddSkip(inner);
|
||||
Ui::AddSkip(inner);
|
||||
|
@ -371,7 +376,9 @@ void CreateModerateMessagesBox(
|
|||
object_ptr<Ui::Checkbox>(
|
||||
box,
|
||||
rpl::conditional(
|
||||
ownedWrap->toggledValue(),
|
||||
(ownedWrap
|
||||
? ownedWrap->toggledValue()
|
||||
: rpl::single(false)),
|
||||
tr::lng_restrict_user(
|
||||
lt_count,
|
||||
rpl::single(participants.size()) | tr::to_count()),
|
||||
|
@ -390,7 +397,9 @@ void CreateModerateMessagesBox(
|
|||
Ui::AddSkip(inner);
|
||||
Ui::AddSkip(inner);
|
||||
|
||||
const auto wrap = inner->add(std::move(ownedWrap));
|
||||
if (ownedWrap) {
|
||||
inner->add(std::move(ownedWrap));
|
||||
|
||||
const auto container = wrap->entity();
|
||||
wrap->toggle(false, anim::type::instant);
|
||||
|
||||
|
@ -468,7 +477,6 @@ void CreateModerateMessagesBox(
|
|||
|
||||
using Flag = ChatRestriction;
|
||||
using Flags = ChatRestrictions;
|
||||
const auto peer = items.front()->history()->peer;
|
||||
const auto chat = peer->asChat();
|
||||
const auto channel = peer->asChannel();
|
||||
const auto defaultRestrictions = chat
|
||||
|
@ -507,6 +515,7 @@ void CreateModerateMessagesBox(
|
|||
prepareFlags,
|
||||
disabledMessages,
|
||||
{ .isForum = peer->isForum() });
|
||||
computeRestrictions = getRestrictions;
|
||||
std::move(changes) | rpl::start_with_next([=] {
|
||||
ban->setChecked(true);
|
||||
}, ban->lifetime());
|
||||
|
@ -514,12 +523,15 @@ void CreateModerateMessagesBox(
|
|||
Ui::AddDivider(container);
|
||||
Ui::AddSkip(container);
|
||||
container->add(std::move(checkboxes));
|
||||
}
|
||||
|
||||
// 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 kick = !wrap || !wrap->toggled();
|
||||
const auto restrictions = computeRestrictions
|
||||
? computeRestrictions()
|
||||
: ChatRestrictions();
|
||||
const auto request = [=](
|
||||
not_null<PeerData*> peer,
|
||||
not_null<ChannelData*> channel) {
|
||||
|
@ -532,10 +544,15 @@ void CreateModerateMessagesBox(
|
|||
nullptr,
|
||||
nullptr);
|
||||
} else {
|
||||
channel->session().api().chatParticipants().kick(
|
||||
channel,
|
||||
const auto block = channel->isMonoforum()
|
||||
? channel->monoforumBroadcast()
|
||||
: channel.get();
|
||||
if (block) {
|
||||
block->session().api().chatParticipants().kick(
|
||||
block,
|
||||
peer,
|
||||
{ channel->restrictions(), 0 });
|
||||
{ block->restrictions(), 0 });
|
||||
}
|
||||
}
|
||||
};
|
||||
sequentiallyRequest(request, controller->collectRequests());
|
||||
|
|
Loading…
Add table
Reference in a new issue