mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/telegramdesktop/tdesktop
synced 2026-09-21 00:23:56 +08:00
Added ban and unban of monoforum peer to sublist menus.
This commit is contained in:
@@ -323,6 +323,7 @@ private:
|
||||
void addThemeEdit();
|
||||
void addToggleNoForwards();
|
||||
void addBlockUser();
|
||||
void addBanFromChannel();
|
||||
void addViewDiscussion();
|
||||
void addDirectMessages();
|
||||
void addToggleTopicClosed();
|
||||
@@ -971,6 +972,53 @@ void Filler::addBlockUser() {
|
||||
}
|
||||
}
|
||||
|
||||
void Filler::addBanFromChannel() {
|
||||
const auto sublist = _sublist;
|
||||
const auto parent = sublist ? sublist->parentChat() : nullptr;
|
||||
const auto broadcast = parent ? parent->monoforumBroadcast() : nullptr;
|
||||
if (!broadcast) {
|
||||
return;
|
||||
}
|
||||
const auto participant = sublist->sublistPeer();
|
||||
if (!broadcast->canRestrictParticipant(participant)) {
|
||||
return;
|
||||
}
|
||||
const auto api = &broadcast->session().api();
|
||||
const auto show = _controller->uiShow();
|
||||
const auto banned = std::make_shared<rpl::variable<bool>>(false);
|
||||
*banned = api->chatParticipants().kickedValue(broadcast, participant);
|
||||
const auto label = [](bool banned) {
|
||||
return banned
|
||||
? tr::lng_context_monoforum_unban(tr::now)
|
||||
: tr::lng_context_monoforum_ban(tr::now);
|
||||
};
|
||||
const auto action = _addAction(
|
||||
label(banned->current()),
|
||||
[=] {
|
||||
if (banned->current()) {
|
||||
api->chatParticipants().unblock(broadcast, participant);
|
||||
return;
|
||||
}
|
||||
show->show(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_profile_sure_kick_channel(
|
||||
tr::now,
|
||||
lt_user,
|
||||
participant->name()),
|
||||
.confirmed = [=](Fn<void()> close) {
|
||||
api->chatParticipants().kick(
|
||||
broadcast,
|
||||
participant,
|
||||
{ broadcast->restrictions(), 0 });
|
||||
close();
|
||||
},
|
||||
.confirmText = tr::lng_box_remove(),
|
||||
}));
|
||||
},
|
||||
(banned->current() ? &st::menuIconUnblock : &st::menuIconBlock));
|
||||
|
||||
SetActionText(action, banned->value() | rpl::map(label));
|
||||
}
|
||||
|
||||
void Filler::addViewDiscussion() {
|
||||
const auto channel = _peer->asBroadcast();
|
||||
if (!channel) {
|
||||
@@ -1864,6 +1912,7 @@ void Filler::fillContextMenuActions() {
|
||||
addBlockUser();
|
||||
}
|
||||
}
|
||||
addBanFromChannel();
|
||||
addClearHistory();
|
||||
addDeleteChat();
|
||||
addLeaveChat();
|
||||
@@ -1915,6 +1964,7 @@ void Filler::fillProfileActions() {
|
||||
addToggleNoForwards();
|
||||
addToggleFolder();
|
||||
addBlockUser();
|
||||
addBanFromChannel();
|
||||
addReport();
|
||||
addLeaveChat();
|
||||
addDeleteContact();
|
||||
@@ -2046,6 +2096,7 @@ void Filler::fillSavedSublistActions() {
|
||||
void Filler::fillMonoforumPeerActions() {
|
||||
Expects(_sublist != nullptr);
|
||||
|
||||
addBanFromChannel();
|
||||
addToggleFee();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user