mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-17 22:57:11 +02:00
Usage limit and requests are mutually exclusive.
This commit is contained in:
parent
2ade6be146
commit
ab60628386
4 changed files with 44 additions and 25 deletions
|
@ -1340,10 +1340,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_group_request_about_channel" = "This channel accepts new subscribers only after they are approved by its admins.";
|
||||
"lng_group_request_sent" = "You will be added to the group once its admins approve your request.";
|
||||
"lng_group_request_sent_channel" = "You will be added to the channel once its admins approve your request.";
|
||||
"lng_group_requests_pending#one" = "{count} pending member request";
|
||||
"lng_group_requests_pending#other" = "{count} pending member requests";
|
||||
"lng_group_requests_pending_channel#one" = "{count} pending subscriber request";
|
||||
"lng_group_requests_pending_channel#other" = "{count} pending subscriber requests";
|
||||
"lng_group_requests_pending#one" = "{count} user requested to join";
|
||||
"lng_group_requests_pending#other" = "{count} users requested to join";
|
||||
"lng_group_requests_status" = "requested to join {date}";
|
||||
"lng_group_requests_add" = "Add to Group";
|
||||
"lng_group_requests_add_channel" = "Add to Channel";
|
||||
|
|
|
@ -107,7 +107,9 @@ void InviteLinks::performCreate(
|
|||
? Flag::f_legacy_revoke_permanent
|
||||
: Flag(0))
|
||||
| (expireDate ? Flag::f_expire_date : Flag(0))
|
||||
| (usageLimit ? Flag::f_usage_limit : Flag(0))
|
||||
| ((!requestApproval && usageLimit)
|
||||
? Flag::f_usage_limit
|
||||
: Flag(0))
|
||||
| (requestApproval ? Flag::f_request_needed : Flag(0))),
|
||||
peer->input,
|
||||
MTP_int(expireDate),
|
||||
|
@ -249,11 +251,14 @@ void InviteLinks::performEdit(
|
|||
callbacks.push_back(std::move(done));
|
||||
}
|
||||
using Flag = MTPmessages_EditExportedChatInvite::Flag;
|
||||
const auto flags = (revoke ? Flag::f_revoked : Flag(0))
|
||||
| (!revoke ? Flag::f_expire_date : Flag(0))
|
||||
| ((!revoke && !requestApproval) ? Flag::f_usage_limit : Flag(0))
|
||||
| ((!revoke && (requestApproval || !usageLimit))
|
||||
? Flag::f_request_needed
|
||||
: Flag(0));
|
||||
_api->request(MTPmessages_EditExportedChatInvite(
|
||||
MTP_flags((revoke ? Flag::f_revoked : Flag(0))
|
||||
| (!revoke ? Flag::f_expire_date : Flag(0))
|
||||
| (!revoke ? Flag::f_usage_limit : Flag(0))
|
||||
| (!revoke ? Flag::f_request_needed : Flag(0))),
|
||||
MTP_flags(flags),
|
||||
peer->input,
|
||||
MTP_string(link),
|
||||
MTP_int(expireDate),
|
||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "ui/wrap/slide_wrap.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "styles/style_settings.h"
|
||||
#include "styles/style_layers.h"
|
||||
|
@ -51,6 +52,8 @@ void EditInviteLinkBox(
|
|||
not_null<GenericBox*> box,
|
||||
const InviteLinkFields &data,
|
||||
Fn<void(InviteLinkFields)> done) {
|
||||
using namespace rpl::mappers;
|
||||
|
||||
const auto link = data.link;
|
||||
const auto isGroup = data.isGroup;
|
||||
box->setTitle(link.isEmpty()
|
||||
|
@ -58,15 +61,19 @@ void EditInviteLinkBox(
|
|||
: tr::lng_group_invite_edit_title());
|
||||
|
||||
const auto container = box->verticalLayout();
|
||||
const auto addTitle = [&](rpl::producer<QString> text) {
|
||||
const auto addTitle = [&](
|
||||
not_null<VerticalLayout*> container,
|
||||
rpl::producer<QString> text,
|
||||
style::margins margins = style::margins()) {
|
||||
container->add(
|
||||
object_ptr<FlatLabel>(
|
||||
container,
|
||||
std::move(text),
|
||||
st::settingsSubsectionTitle),
|
||||
st::settingsSubsectionTitlePadding);
|
||||
st::settingsSubsectionTitlePadding + margins);
|
||||
};
|
||||
const auto addDivider = [&](
|
||||
not_null<VerticalLayout*> container,
|
||||
rpl::producer<QString> text,
|
||||
style::margins margins = style::margins()) {
|
||||
container->add(
|
||||
|
@ -80,19 +87,27 @@ void EditInviteLinkBox(
|
|||
margins);
|
||||
};
|
||||
|
||||
addTitle(tr::lng_group_invite_expire_title());
|
||||
addTitle(container, tr::lng_group_invite_expire_title());
|
||||
const auto expiresWrap = container->add(
|
||||
object_ptr<VerticalLayout>(container),
|
||||
style::margins(0, 0, 0, st::settingsSectionSkip));
|
||||
addDivider(
|
||||
tr::lng_group_invite_expire_about(),
|
||||
style::margins(0, 0, 0, st::settingsSectionSkip));
|
||||
container,
|
||||
tr::lng_group_invite_expire_about());
|
||||
|
||||
addTitle(tr::lng_group_invite_usage_title());
|
||||
const auto usagesWrap = container->add(
|
||||
object_ptr<VerticalLayout>(container),
|
||||
const auto usagesSlide = container->add(
|
||||
object_ptr<SlideWrap<VerticalLayout>>(
|
||||
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));
|
||||
const auto usagesWrap = usagesInner->add(
|
||||
object_ptr<VerticalLayout>(usagesInner),
|
||||
style::margins(0, 0, 0, st::settingsSectionSkip));
|
||||
addDivider(tr::lng_group_invite_usage_about());
|
||||
addDivider(usagesInner, tr::lng_group_invite_usage_about());
|
||||
|
||||
static const auto addButton = [](
|
||||
not_null<VerticalLayout*> container,
|
||||
|
@ -272,7 +287,7 @@ void EditInviteLinkBox(
|
|||
style::margins{ 0, buttonSkip, 0, buttonSkip });
|
||||
requestApproval->toggleOn(state->requestApproval.value());
|
||||
state->requestApproval = requestApproval->toggledValue();
|
||||
addDivider(rpl::conditional(
|
||||
addDivider(container, rpl::conditional(
|
||||
state->requestApproval.value(),
|
||||
(isGroup
|
||||
? tr::lng_group_invite_about_approve()
|
||||
|
@ -281,6 +296,9 @@ void EditInviteLinkBox(
|
|||
? tr::lng_group_invite_about_no_approve()
|
||||
: tr::lng_group_invite_about_no_approve_channel())));
|
||||
|
||||
usagesSlide->toggleOn(state->requestApproval.value() | rpl::map(!_1));
|
||||
usagesSlide->finishAnimating();
|
||||
|
||||
const auto &saveLabel = link.isEmpty()
|
||||
? tr::lng_formatting_link_create
|
||||
: tr::lng_settings_save;
|
||||
|
|
|
@ -47,12 +47,10 @@ RequestsBar::RequestsBar(
|
|||
) | rpl::start_with_next([=](RequestsBarContent &&content) {
|
||||
_content = content;
|
||||
if (_content.count > 0) {
|
||||
_text = (_content.isGroup
|
||||
? tr::lng_group_requests_pending
|
||||
: tr::lng_group_requests_pending_channel)(
|
||||
tr::now,
|
||||
lt_count_decimal,
|
||||
_content.count);
|
||||
_text = tr::lng_group_requests_pending(
|
||||
tr::now,
|
||||
lt_count_decimal,
|
||||
_content.count);
|
||||
}
|
||||
_userpics->update(_content.users, !_wrap.isHidden());
|
||||
_inner->update();
|
||||
|
|
Loading…
Add table
Reference in a new issue