mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
Hide "Request admin approval" in public peers.
This commit is contained in:
parent
7a57174ab1
commit
a92394a81f
@ -1331,7 +1331,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_group_invite_qr_title" = "Invite by QR Code";
|
||||
"lng_group_invite_qr_about" = "Everyone on Telegram can scan this code to join your group.";
|
||||
"lng_group_invite_qr_copied" = "QR Code copied to clipboard.";
|
||||
"lng_group_invite_request_approve" = "Approve everyone who joins";
|
||||
"lng_group_invite_request_approve" = "Request admin approval";
|
||||
"lng_group_invite_about_approve" = "New users will be able to join the group only after having been approved by the admins.";
|
||||
"lng_group_invite_about_no_approve" = "New users will be able to join the group without being approved by the admins.";
|
||||
"lng_group_invite_about_approve_channel" = "New users will be able to join the channel only after having been approved by the admins.";
|
||||
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_changes.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_histories.h"
|
||||
@ -1211,9 +1212,10 @@ void EditLink(
|
||||
}
|
||||
};
|
||||
const auto isGroup = !peer->isBroadcast();
|
||||
const auto isPublic = peer->isChannel() && peer->asChannel()->isPublic();
|
||||
*box = Ui::show(
|
||||
(creating
|
||||
? Box(Ui::CreateInviteLinkBox, isGroup, done)
|
||||
? Box(Ui::CreateInviteLinkBox, isGroup, isPublic, done)
|
||||
: Box(
|
||||
Ui::EditInviteLinkBox,
|
||||
Fields{
|
||||
@ -1223,6 +1225,7 @@ void EditLink(
|
||||
.usageLimit = data.usageLimit,
|
||||
.requestApproval = data.requestApproval,
|
||||
.isGroup = isGroup,
|
||||
.isPublic = isPublic,
|
||||
},
|
||||
done)),
|
||||
Ui::LayerOption::KeepOther);
|
||||
|
@ -57,6 +57,7 @@ void EditInviteLinkBox(
|
||||
|
||||
const auto link = data.link;
|
||||
const auto isGroup = data.isGroup;
|
||||
const auto isPublic = data.isPublic;
|
||||
box->setTitle(link.isEmpty()
|
||||
? tr::lng_group_invite_new_title()
|
||||
: tr::lng_group_invite_edit_title());
|
||||
@ -64,14 +65,14 @@ void EditInviteLinkBox(
|
||||
const auto container = box->verticalLayout();
|
||||
const auto addTitle = [&](
|
||||
not_null<VerticalLayout*> container,
|
||||
rpl::producer<QString> text,
|
||||
style::margins margins = style::margins()) {
|
||||
rpl::producer<QString> text) {
|
||||
container->add(
|
||||
object_ptr<FlatLabel>(
|
||||
container,
|
||||
std::move(text),
|
||||
st::settingsSubsectionTitle),
|
||||
st::settingsSubsectionTitlePadding + margins);
|
||||
(st::settingsSubsectionTitlePadding
|
||||
+ style::margins(0, st::settingsSectionSkip, 0, 0)));
|
||||
};
|
||||
const auto addDivider = [&](
|
||||
not_null<VerticalLayout*> container,
|
||||
@ -105,25 +106,43 @@ void EditInviteLinkBox(
|
||||
const auto state = box->lifetime().make_state<State>(State{
|
||||
.expireValue = expire,
|
||||
.usageValue = usage,
|
||||
.requestApproval = data.requestApproval,
|
||||
.requestApproval = (data.requestApproval && !isPublic),
|
||||
});
|
||||
|
||||
const auto requestApproval = container->add(
|
||||
object_ptr<SettingsButton>(
|
||||
const auto requestApproval = isPublic
|
||||
? nullptr
|
||||
: container->add(
|
||||
object_ptr<SettingsButton>(
|
||||
container,
|
||||
tr::lng_group_invite_request_approve(),
|
||||
st::settingsButton),
|
||||
style::margins{ 0, 0, 0, st::settingsSectionSkip });
|
||||
if (requestApproval) {
|
||||
requestApproval->toggleOn(state->requestApproval.value());
|
||||
state->requestApproval = requestApproval->toggledValue();
|
||||
addDivider(container, rpl::conditional(
|
||||
state->requestApproval.value(),
|
||||
(isGroup
|
||||
? tr::lng_group_invite_about_approve()
|
||||
: tr::lng_group_invite_about_approve_channel()),
|
||||
(isGroup
|
||||
? tr::lng_group_invite_about_no_approve()
|
||||
: tr::lng_group_invite_about_no_approve_channel())));
|
||||
}
|
||||
|
||||
const auto labelField = container->add(
|
||||
object_ptr<Ui::InputField>(
|
||||
container,
|
||||
tr::lng_group_invite_request_approve(),
|
||||
st::settingsButton),
|
||||
style::margins{ 0, 0, 0, st::settingsSectionSkip });
|
||||
requestApproval->toggleOn(state->requestApproval.value());
|
||||
state->requestApproval = requestApproval->toggledValue();
|
||||
addDivider(container, rpl::conditional(
|
||||
state->requestApproval.value(),
|
||||
(isGroup
|
||||
? tr::lng_group_invite_about_approve()
|
||||
: tr::lng_group_invite_about_approve_channel()),
|
||||
(isGroup
|
||||
? tr::lng_group_invite_about_no_approve()
|
||||
: tr::lng_group_invite_about_no_approve_channel())));
|
||||
st::defaultInputField,
|
||||
tr::lng_group_invite_label_header(),
|
||||
data.label),
|
||||
style::margins(
|
||||
st::settingsSubsectionTitlePadding.left(),
|
||||
st::settingsSectionSkip,
|
||||
st::settingsSubsectionTitlePadding.right(),
|
||||
st::settingsSectionSkip * 2));
|
||||
labelField->setMaxLength(kMaxLabelLength);
|
||||
addDivider(container, tr::lng_group_invite_label_about());
|
||||
|
||||
addTitle(container, tr::lng_group_invite_expire_title());
|
||||
const auto expiresWrap = container->add(
|
||||
@ -138,10 +157,7 @@ void EditInviteLinkBox(
|
||||
container,
|
||||
object_ptr<VerticalLayout>(container)));
|
||||
const auto usagesInner = usagesSlide->entity();
|
||||
addTitle(
|
||||
usagesInner,
|
||||
tr::lng_group_invite_usage_title(),
|
||||
style::margins(0, st::settingsSectionSkip, 0, 0));
|
||||
addTitle(usagesInner, tr::lng_group_invite_usage_title());
|
||||
const auto usagesWrap = usagesInner->add(
|
||||
object_ptr<VerticalLayout>(usagesInner),
|
||||
style::margins(0, 0, 0, st::settingsSectionSkip));
|
||||
@ -297,20 +313,6 @@ void EditInviteLinkBox(
|
||||
|
||||
regenerate();
|
||||
|
||||
const auto labelField = container->add(
|
||||
object_ptr<Ui::InputField>(
|
||||
container,
|
||||
st::defaultInputField,
|
||||
tr::lng_group_invite_label_header(),
|
||||
data.label),
|
||||
style::margins(
|
||||
st::settingsSubsectionTitlePadding.left(),
|
||||
st::settingsSectionSkip,
|
||||
st::settingsSubsectionTitlePadding.right(),
|
||||
st::settingsSectionSkip * 2));
|
||||
labelField->setMaxLength(kMaxLabelLength);
|
||||
addDivider(container, tr::lng_group_invite_label_about());
|
||||
|
||||
usagesSlide->toggleOn(state->requestApproval.value() | rpl::map(!_1));
|
||||
usagesSlide->finishAnimating();
|
||||
|
||||
@ -334,6 +336,7 @@ void EditInviteLinkBox(
|
||||
.usageLimit = usageLimit,
|
||||
.requestApproval = state->requestApproval.current(),
|
||||
.isGroup = isGroup,
|
||||
.isPublic = isPublic,
|
||||
});
|
||||
});
|
||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||
@ -342,10 +345,11 @@ void EditInviteLinkBox(
|
||||
void CreateInviteLinkBox(
|
||||
not_null<GenericBox*> box,
|
||||
bool isGroup,
|
||||
bool isPublic,
|
||||
Fn<void(InviteLinkFields)> done) {
|
||||
EditInviteLinkBox(
|
||||
box,
|
||||
InviteLinkFields{ .isGroup = isGroup },
|
||||
InviteLinkFields{ .isGroup = isGroup, .isPublic = isPublic },
|
||||
std::move(done));
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ struct InviteLinkFields {
|
||||
int usageLimit = 0;
|
||||
bool requestApproval = false;
|
||||
bool isGroup = false;
|
||||
bool isPublic = false;
|
||||
};
|
||||
|
||||
void EditInviteLinkBox(
|
||||
@ -28,6 +29,7 @@ void EditInviteLinkBox(
|
||||
void CreateInviteLinkBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
bool isGroup,
|
||||
bool isPublic,
|
||||
Fn<void(InviteLinkFields)> done);
|
||||
|
||||
} // namespace Ui
|
||||
|
Loading…
Reference in New Issue
Block a user