From 721a642a2fe2ab2c57eb220d616653585f268d6a Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 17 Nov 2024 10:37:40 +0300 Subject: [PATCH] Added date to info who promoted or restricted participants in menu. --- Telegram/Resources/langs/lang.strings | 6 +- .../boxes/peers/edit_participants_box.cpp | 75 ++++++++++++------- 2 files changed, 51 insertions(+), 30 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 64c038f05..9a36efb1d 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -4359,7 +4359,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_rights_edit_admin_rank_about" = "A title that members will see instead of '{title}'."; "lng_rights_about_add_admins_yes" = "This admin will be able to add new admins with equal or fewer rights."; "lng_rights_about_add_admins_no" = "This admin will not be able to add new admins."; -"lng_rights_about_by" = "This admin promoted by {user} at {date}."; +"lng_rights_about_by" = "This admin promoted by {user} on {date}."; "lng_rights_about_admin_cant_edit" = "You can't edit the rights of this admin."; "lng_rights_about_restriction_cant_edit" = "You cannot change the restrictions for this user."; @@ -4438,8 +4438,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_restricted_by" = "Restricted by {user} on {date}."; +"lng_rights_chat_banned_by" = "Banned by {user} on {date}."; "lng_rights_chat_banned_until_header" = "Restricted until"; "lng_rights_chat_banned_forever" = "Forever"; "lng_rights_chat_banned_day#one" = "For {count} day"; diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index 345d9880e..d1b6d7a2d 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -30,10 +30,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_changes.h" #include "base/unixtime.h" #include "ui/effects/outline_segments.h" +#include "ui/widgets/menu/menu_multiline_action.h" #include "ui/widgets/popup_menu.h" +#include "ui/text/text_utilities.h" #include "info/profile/info_profile_values.h" #include "window/window_session_controller.h" #include "history/history.h" +#include "styles/style_chat.h" #include "styles/style_menu_icons.h" namespace { @@ -1645,6 +1648,51 @@ base::unique_qptr ParticipantsBoxController::rowContextMenu( auto result = base::make_unique_q( parent, st::popupMenuWithIcons); + const auto addToEnd = gsl::finally([&] { + const auto addInfoAction = [&]( + not_null by, + tr::phrase phrase, + TimeId since) { + auto text = phrase( + tr::now, + lt_user, + Ui::Text::Bold(by->name()), + lt_date, + Ui::Text::Bold( + langDateTimeFull(base::unixtime::parse(since))), + Ui::Text::WithEntities); + auto button = base::make_unique_q( + result->menu(), + result->st().menu, + st::historyHasCustomEmoji, + st::historyHasCustomEmojiPosition, + std::move(text)); + if (const auto n = _navigation) { + button->setClickedCallback([=] { + n->parentController()->show(PrepareShortInfoBox(by, n)); + }); + } + result->addSeparator(); + result->addAction(std::move(button)); + }; + + if (const auto by = _additional.restrictedBy(participant)) { + if (const auto since = _additional.restrictedSince(participant)) { + addInfoAction( + by, + _additional.isKicked(participant) + ? tr::lng_rights_chat_banned_by + : tr::lng_rights_chat_restricted_by, + since); + } + } else if (user) { + if (const auto by = _additional.adminPromotedBy(user)) { + if (const auto since = _additional.adminPromotedSince(user)) { + addInfoAction(by, tr::lng_rights_about_by, since); + } + } + } + }); if (_navigation) { result->addAction( (participant->isUser() @@ -1658,33 +1706,6 @@ base::unique_qptr ParticipantsBoxController::rowContextMenu( ? &st::menuIconProfile : &st::menuIconInfo)); } - if (const auto by = _additional.restrictedBy(participant)) { - result->addAction( - (_role == Role::Kicked - ? tr::lng_channel_banned_status_removed_by - : tr::lng_channel_banned_status_restricted_by)( - tr::now, - lt_user, - by->name()), - crl::guard(this, [=] { - _navigation->parentController()->show( - PrepareShortInfoBox(by, _navigation)); - }), - &st::menuIconAdmin); - } else if (user) { - if (const auto by = _additional.adminPromotedBy(user)) { - result->addAction( - tr::lng_channel_admin_status_promoted_by( - tr::now, - lt_user, - by->name()), - crl::guard(this, [=] { - _navigation->parentController()->show( - PrepareShortInfoBox(by, _navigation)); - }), - &st::menuIconAdmin); - } - } if (_role == Role::Kicked) { if (_peer->isMegagroup() && _additional.canRestrictParticipant(participant)) {