mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Hide "Request admin approval" in public peers.
This commit is contained in:
parent
7a57174ab1
commit
a92394a81f
4 changed files with 49 additions and 40 deletions
|
@ -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_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_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_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_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_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.";
|
"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_peer.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
#include "data/data_channel.h"
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_histories.h"
|
#include "data/data_histories.h"
|
||||||
|
@ -1211,9 +1212,10 @@ void EditLink(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const auto isGroup = !peer->isBroadcast();
|
const auto isGroup = !peer->isBroadcast();
|
||||||
|
const auto isPublic = peer->isChannel() && peer->asChannel()->isPublic();
|
||||||
*box = Ui::show(
|
*box = Ui::show(
|
||||||
(creating
|
(creating
|
||||||
? Box(Ui::CreateInviteLinkBox, isGroup, done)
|
? Box(Ui::CreateInviteLinkBox, isGroup, isPublic, done)
|
||||||
: Box(
|
: Box(
|
||||||
Ui::EditInviteLinkBox,
|
Ui::EditInviteLinkBox,
|
||||||
Fields{
|
Fields{
|
||||||
|
@ -1223,6 +1225,7 @@ void EditLink(
|
||||||
.usageLimit = data.usageLimit,
|
.usageLimit = data.usageLimit,
|
||||||
.requestApproval = data.requestApproval,
|
.requestApproval = data.requestApproval,
|
||||||
.isGroup = isGroup,
|
.isGroup = isGroup,
|
||||||
|
.isPublic = isPublic,
|
||||||
},
|
},
|
||||||
done)),
|
done)),
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
|
|
|
@ -57,6 +57,7 @@ void EditInviteLinkBox(
|
||||||
|
|
||||||
const auto link = data.link;
|
const auto link = data.link;
|
||||||
const auto isGroup = data.isGroup;
|
const auto isGroup = data.isGroup;
|
||||||
|
const auto isPublic = data.isPublic;
|
||||||
box->setTitle(link.isEmpty()
|
box->setTitle(link.isEmpty()
|
||||||
? tr::lng_group_invite_new_title()
|
? tr::lng_group_invite_new_title()
|
||||||
: tr::lng_group_invite_edit_title());
|
: tr::lng_group_invite_edit_title());
|
||||||
|
@ -64,14 +65,14 @@ void EditInviteLinkBox(
|
||||||
const auto container = box->verticalLayout();
|
const auto container = box->verticalLayout();
|
||||||
const auto addTitle = [&](
|
const auto addTitle = [&](
|
||||||
not_null<VerticalLayout*> container,
|
not_null<VerticalLayout*> container,
|
||||||
rpl::producer<QString> text,
|
rpl::producer<QString> text) {
|
||||||
style::margins margins = style::margins()) {
|
|
||||||
container->add(
|
container->add(
|
||||||
object_ptr<FlatLabel>(
|
object_ptr<FlatLabel>(
|
||||||
container,
|
container,
|
||||||
std::move(text),
|
std::move(text),
|
||||||
st::settingsSubsectionTitle),
|
st::settingsSubsectionTitle),
|
||||||
st::settingsSubsectionTitlePadding + margins);
|
(st::settingsSubsectionTitlePadding
|
||||||
|
+ style::margins(0, st::settingsSectionSkip, 0, 0)));
|
||||||
};
|
};
|
||||||
const auto addDivider = [&](
|
const auto addDivider = [&](
|
||||||
not_null<VerticalLayout*> container,
|
not_null<VerticalLayout*> container,
|
||||||
|
@ -105,25 +106,43 @@ void EditInviteLinkBox(
|
||||||
const auto state = box->lifetime().make_state<State>(State{
|
const auto state = box->lifetime().make_state<State>(State{
|
||||||
.expireValue = expire,
|
.expireValue = expire,
|
||||||
.usageValue = usage,
|
.usageValue = usage,
|
||||||
.requestApproval = data.requestApproval,
|
.requestApproval = (data.requestApproval && !isPublic),
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto requestApproval = container->add(
|
const auto requestApproval = isPublic
|
||||||
object_ptr<SettingsButton>(
|
? 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,
|
container,
|
||||||
tr::lng_group_invite_request_approve(),
|
st::defaultInputField,
|
||||||
st::settingsButton),
|
tr::lng_group_invite_label_header(),
|
||||||
style::margins{ 0, 0, 0, st::settingsSectionSkip });
|
data.label),
|
||||||
requestApproval->toggleOn(state->requestApproval.value());
|
style::margins(
|
||||||
state->requestApproval = requestApproval->toggledValue();
|
st::settingsSubsectionTitlePadding.left(),
|
||||||
addDivider(container, rpl::conditional(
|
st::settingsSectionSkip,
|
||||||
state->requestApproval.value(),
|
st::settingsSubsectionTitlePadding.right(),
|
||||||
(isGroup
|
st::settingsSectionSkip * 2));
|
||||||
? tr::lng_group_invite_about_approve()
|
labelField->setMaxLength(kMaxLabelLength);
|
||||||
: tr::lng_group_invite_about_approve_channel()),
|
addDivider(container, tr::lng_group_invite_label_about());
|
||||||
(isGroup
|
|
||||||
? tr::lng_group_invite_about_no_approve()
|
|
||||||
: tr::lng_group_invite_about_no_approve_channel())));
|
|
||||||
|
|
||||||
addTitle(container, tr::lng_group_invite_expire_title());
|
addTitle(container, tr::lng_group_invite_expire_title());
|
||||||
const auto expiresWrap = container->add(
|
const auto expiresWrap = container->add(
|
||||||
|
@ -138,10 +157,7 @@ void EditInviteLinkBox(
|
||||||
container,
|
container,
|
||||||
object_ptr<VerticalLayout>(container)));
|
object_ptr<VerticalLayout>(container)));
|
||||||
const auto usagesInner = usagesSlide->entity();
|
const auto usagesInner = usagesSlide->entity();
|
||||||
addTitle(
|
addTitle(usagesInner, tr::lng_group_invite_usage_title());
|
||||||
usagesInner,
|
|
||||||
tr::lng_group_invite_usage_title(),
|
|
||||||
style::margins(0, st::settingsSectionSkip, 0, 0));
|
|
||||||
const auto usagesWrap = usagesInner->add(
|
const auto usagesWrap = usagesInner->add(
|
||||||
object_ptr<VerticalLayout>(usagesInner),
|
object_ptr<VerticalLayout>(usagesInner),
|
||||||
style::margins(0, 0, 0, st::settingsSectionSkip));
|
style::margins(0, 0, 0, st::settingsSectionSkip));
|
||||||
|
@ -297,20 +313,6 @@ void EditInviteLinkBox(
|
||||||
|
|
||||||
regenerate();
|
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->toggleOn(state->requestApproval.value() | rpl::map(!_1));
|
||||||
usagesSlide->finishAnimating();
|
usagesSlide->finishAnimating();
|
||||||
|
|
||||||
|
@ -334,6 +336,7 @@ void EditInviteLinkBox(
|
||||||
.usageLimit = usageLimit,
|
.usageLimit = usageLimit,
|
||||||
.requestApproval = state->requestApproval.current(),
|
.requestApproval = state->requestApproval.current(),
|
||||||
.isGroup = isGroup,
|
.isGroup = isGroup,
|
||||||
|
.isPublic = isPublic,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||||
|
@ -342,10 +345,11 @@ void EditInviteLinkBox(
|
||||||
void CreateInviteLinkBox(
|
void CreateInviteLinkBox(
|
||||||
not_null<GenericBox*> box,
|
not_null<GenericBox*> box,
|
||||||
bool isGroup,
|
bool isGroup,
|
||||||
|
bool isPublic,
|
||||||
Fn<void(InviteLinkFields)> done) {
|
Fn<void(InviteLinkFields)> done) {
|
||||||
EditInviteLinkBox(
|
EditInviteLinkBox(
|
||||||
box,
|
box,
|
||||||
InviteLinkFields{ .isGroup = isGroup },
|
InviteLinkFields{ .isGroup = isGroup, .isPublic = isPublic },
|
||||||
std::move(done));
|
std::move(done));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ struct InviteLinkFields {
|
||||||
int usageLimit = 0;
|
int usageLimit = 0;
|
||||||
bool requestApproval = false;
|
bool requestApproval = false;
|
||||||
bool isGroup = false;
|
bool isGroup = false;
|
||||||
|
bool isPublic = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
void EditInviteLinkBox(
|
void EditInviteLinkBox(
|
||||||
|
@ -28,6 +29,7 @@ void EditInviteLinkBox(
|
||||||
void CreateInviteLinkBox(
|
void CreateInviteLinkBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
bool isGroup,
|
bool isGroup,
|
||||||
|
bool isPublic,
|
||||||
Fn<void(InviteLinkFields)> done);
|
Fn<void(InviteLinkFields)> done);
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
Loading…
Add table
Reference in a new issue