mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 13:47:05 +02:00
Added date of restriction to EditRestrictedBox.
This commit is contained in:
parent
686e9643ad
commit
edf1417bbb
6 changed files with 65 additions and 14 deletions
|
@ -4303,6 +4303,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_rights_chat_files" = "Files";
|
||||
"lng_rights_chat_voice_messages" = "Voice messages";
|
||||
"lng_rights_chat_video_messages" = "Video messages";
|
||||
"lng_rights_chat_restricted_by" = "Restricted by {user} at {date}.";
|
||||
"lng_rights_chat_banned_by" = "Banned by {user} at {date}.";
|
||||
"lng_rights_chat_banned_until_header" = "Restricted until";
|
||||
"lng_rights_chat_banned_forever" = "Forever";
|
||||
"lng_rights_chat_banned_day#one" = "For {count} day";
|
||||
|
|
|
@ -1354,7 +1354,9 @@ void AddSpecialBoxController::showRestricted(
|
|||
_peer,
|
||||
user,
|
||||
_additional.adminRights(user).has_value(),
|
||||
currentRights);
|
||||
currentRights,
|
||||
_additional.restrictedBy(user),
|
||||
_additional.restrictedSince(user));
|
||||
if (_additional.canRestrictParticipant(user)) {
|
||||
const auto done = crl::guard(this, [=](
|
||||
ChatRestrictionsInfo newRights) {
|
||||
|
|
|
@ -705,9 +705,13 @@ EditRestrictedBox::EditRestrictedBox(
|
|||
not_null<PeerData*> peer,
|
||||
not_null<UserData*> user,
|
||||
bool hasAdminRights,
|
||||
ChatRestrictionsInfo rights)
|
||||
ChatRestrictionsInfo rights,
|
||||
UserData *by,
|
||||
TimeId since)
|
||||
: EditParticipantBox(nullptr, peer, user, hasAdminRights)
|
||||
, _oldRights(rights) {
|
||||
, _oldRights(rights)
|
||||
, _by(by)
|
||||
, _since(since) {
|
||||
}
|
||||
|
||||
void EditRestrictedBox::prepare() {
|
||||
|
@ -782,6 +786,29 @@ void EditRestrictedBox::prepare() {
|
|||
// tr::lng_rights_chat_banned_block(tr::now),
|
||||
// st::boxLinkButton));
|
||||
|
||||
if (_since) {
|
||||
const auto parsed = base::unixtime::parse(_since);
|
||||
const auto inner = addControl(object_ptr<Ui::VerticalLayout>(this));
|
||||
const auto isBanned = (_oldRights.flags
|
||||
& ChatRestriction::ViewMessages);
|
||||
Ui::AddSkip(inner);
|
||||
const auto label = Ui::AddDividerText(
|
||||
inner,
|
||||
(isBanned
|
||||
? tr::lng_rights_chat_banned_by
|
||||
: tr::lng_rights_chat_restricted_by)(
|
||||
lt_user,
|
||||
rpl::single(_by
|
||||
? Ui::Text::Link(_by->name(), 1)
|
||||
: TextWithEntities(QString::fromUtf8("\U0001F47B"))),
|
||||
lt_date,
|
||||
rpl::single(TextWithEntities{ langDateTimeFull(parsed) }),
|
||||
Ui::Text::WithEntities));
|
||||
if (_by) {
|
||||
label->setLink(1, _by->createOpenLink());
|
||||
}
|
||||
}
|
||||
|
||||
if (canSave()) {
|
||||
const auto save = [=, value = getRestrictions] {
|
||||
if (!_saveCallback) {
|
||||
|
|
|
@ -146,7 +146,9 @@ public:
|
|||
not_null<PeerData*> peer,
|
||||
not_null<UserData*> user,
|
||||
bool hasAdminRights,
|
||||
ChatRestrictionsInfo rights);
|
||||
ChatRestrictionsInfo rights,
|
||||
UserData *by,
|
||||
TimeId since);
|
||||
|
||||
void setSaveCallback(
|
||||
Fn<void(ChatRestrictionsInfo, ChatRestrictionsInfo)> callback) {
|
||||
|
@ -170,6 +172,8 @@ private:
|
|||
TimeId getRealUntilValue() const;
|
||||
|
||||
const ChatRestrictionsInfo _oldRights;
|
||||
UserData *_by = nullptr;
|
||||
TimeId _since = 0;
|
||||
TimeId _until = 0;
|
||||
Fn<void(ChatRestrictionsInfo, ChatRestrictionsInfo)> _saveCallback;
|
||||
|
||||
|
|
|
@ -1804,7 +1804,9 @@ void ParticipantsBoxController::showRestricted(not_null<UserData*> user) {
|
|||
_peer,
|
||||
user,
|
||||
hasAdminRights,
|
||||
currentRights);
|
||||
currentRights,
|
||||
_additional.restrictedBy(user),
|
||||
_additional.restrictedSince(user));
|
||||
if (_additional.canRestrictParticipant(user)) {
|
||||
const auto done = crl::guard(this, [=](
|
||||
ChatRestrictionsInfo newRights) {
|
||||
|
|
|
@ -1509,15 +1509,28 @@ void InnerWidget::suggestRestrictParticipant(
|
|||
}
|
||||
_menu->addAction(tr::lng_context_restrict_user(tr::now), [=] {
|
||||
const auto user = participant->asUser();
|
||||
auto editRestrictions = [=](bool hasAdminRights, ChatRestrictionsInfo currentRights) {
|
||||
auto editRestrictions = [=](
|
||||
bool hasAdminRights,
|
||||
ChatRestrictionsInfo currentRights,
|
||||
UserData *by,
|
||||
TimeId since) {
|
||||
auto weak = QPointer<InnerWidget>(this);
|
||||
auto weakBox = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
auto box = Box<EditRestrictedBox>(_channel, user, hasAdminRights, currentRights);
|
||||
auto box = Box<EditRestrictedBox>(
|
||||
_channel,
|
||||
user,
|
||||
hasAdminRights,
|
||||
currentRights,
|
||||
by,
|
||||
since);
|
||||
box->setSaveCallback([=](
|
||||
ChatRestrictionsInfo oldRights,
|
||||
ChatRestrictionsInfo newRights) {
|
||||
if (weak) {
|
||||
weak->restrictParticipant(participant, oldRights, newRights);
|
||||
weak->restrictParticipant(
|
||||
participant,
|
||||
oldRights,
|
||||
newRights);
|
||||
}
|
||||
if (*weakBox) {
|
||||
(*weakBox)->closeBox();
|
||||
|
@ -1544,7 +1557,7 @@ void InnerWidget::suggestRestrictParticipant(
|
|||
});
|
||||
*weakBox = _controller->show(Ui::MakeConfirmBox({ text, sure }));
|
||||
} else if (base::contains(_admins, user)) {
|
||||
editRestrictions(true, ChatRestrictionsInfo());
|
||||
editRestrictions(true, {}, nullptr, 0);
|
||||
} else {
|
||||
_api.request(MTPchannels_GetParticipant(
|
||||
_channel->inputChannel,
|
||||
|
@ -1558,15 +1571,16 @@ void InnerWidget::suggestRestrictParticipant(
|
|||
using Type = Api::ChatParticipant::Type;
|
||||
if (participant.type() == Type::Creator
|
||||
|| participant.type() == Type::Admin) {
|
||||
editRestrictions(true, {});
|
||||
} else if (participant.type() == Type::Restricted
|
||||
|| participant.type() == Type::Banned) {
|
||||
editRestrictions(true, {}, nullptr, 0);
|
||||
} else if (const auto since = participant.restrictedSince()) {
|
||||
editRestrictions(
|
||||
false,
|
||||
participant.restrictions());
|
||||
participant.restrictions(),
|
||||
user->owner().user(participant.by()),
|
||||
since);
|
||||
}
|
||||
}).fail([=] {
|
||||
editRestrictions(false, ChatRestrictionsInfo());
|
||||
editRestrictions(false, {}, nullptr, 0);
|
||||
}).send();
|
||||
}
|
||||
}, &st::menuIconPermissions);
|
||||
|
|
Loading…
Add table
Reference in a new issue