2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Allow creating approve-only invite links.

This commit is contained in:
John Preston
2021-10-12 12:39:07 +04:00
parent e471d61d7a
commit 3af3f85f82
20 changed files with 259 additions and 52 deletions

View File

@@ -297,6 +297,7 @@ private:
void fillSignaturesButton();
void fillHistoryVisibilityButton();
void fillManageSection();
void fillPendingRequestsButton();
void submitTitle();
void submitDescription();
@@ -845,6 +846,8 @@ void Controller::fillHistoryVisibilityButton() {
void Controller::fillManageSection() {
Expects(_controls.buttonsLayout != nullptr);
using namespace rpl::mappers;
const auto chat = _peer->asChat();
const auto channel = _peer->asChannel();
const auto isChannel = (!chat);
@@ -1042,6 +1045,9 @@ void Controller::fillManageSection() {
},
st::infoIconMembers);
}
fillPendingRequestsButton();
if (canViewKicked) {
AddButtonWithCount(
_controls.buttonsLayout,
@@ -1089,6 +1095,42 @@ void Controller::fillManageSection() {
}
}
void Controller::fillPendingRequestsButton() {
auto pendingRequestsCount = Info::Profile::MigratedOrMeValue(
_peer
) | rpl::map(
Info::Profile::PendingRequestsCountValue
) | rpl::flatten_latest(
) | rpl::start_spawning(_controls.buttonsLayout->lifetime());
const auto wrap = _controls.buttonsLayout->add(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
_controls.buttonsLayout,
object_ptr<Ui::VerticalLayout>(
_controls.buttonsLayout)));
AddButtonWithCount(
wrap->entity(),
(_isGroup
? tr::lng_manage_peer_requests()
: tr::lng_manage_peer_requests_channel()),
rpl::duplicate(pendingRequestsCount) | ToPositiveNumberString(),
[=] {
_navigation->parentController()->show(
Box( // #TODO requests
ManageInviteLinksBox,
_peer,
_peer->session().user(),
0,
0),
Ui::LayerOption::KeepOther);
},
st::infoIconRequests);
std::move(
pendingRequestsCount
) | rpl::start_with_next([=](int count) {
wrap->toggle(count > 0, anim::type::instant);
}, wrap->lifetime());
}
void Controller::submitTitle() {
Expects(_controls.title != nullptr);

View File

@@ -943,7 +943,8 @@ void EditLink(
peer,
finish,
result.expireDate,
result.usageLimit);
result.usageLimit,
result.requestApproval);
} else {
peer->session().api().inviteLinks().edit(
peer,
@@ -951,18 +952,22 @@ void EditLink(
result.link,
result.expireDate,
result.usageLimit,
result.requestApproval,
finish);
}
};
const auto isGroup = !peer->isBroadcast();
*box = Ui::show(
(creating
? Box(Ui::CreateInviteLinkBox, done)
? Box(Ui::CreateInviteLinkBox, isGroup, done)
: Box(
Ui::EditInviteLinkBox,
Fields{
.link = data.link,
.expireDate = data.expireDate,
.usageLimit = data.usageLimit
.usageLimit = data.usageLimit,
.requestApproval = data.requestApproval,
.isGroup = isGroup,
},
done)),
Ui::LayerOption::KeepOther);