diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index bcec388ee2..541a65a91b 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2221,6 +2221,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_you_paid_stars#one" = "You paid {count} Star."; "lng_you_paid_stars#other" = "You paid {count} Stars."; +"lng_you_joined_group" = "You joined this group"; + "lng_similar_channels_title" = "Similar channels"; "lng_similar_channels_view_all" = "View all"; "lng_similar_channels_more" = "More Channels"; diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index caa4ca26a9..e86aca0b39 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -113,6 +113,12 @@ base::options::toggle ShowPeerIdBelowAbout({ " Add contact IDs to exported data.", }); +base::options::toggle ShowChannelJoinedBelowAbout({ + .id = kOptionShowChannelJoinedBelowAbout, + .name = "Show Channel Joined Date in Profile", + .description = "Show when you join Channel under its Description.", +}); + [[nodiscard]] rpl::producer UsernamesSubtext( not_null peer, rpl::producer fallback) { @@ -183,24 +189,47 @@ base::options::toggle ShowPeerIdBelowAbout({ return result; } -[[nodiscard]] rpl::producer AboutWithIdValue( +[[nodiscard]] rpl::producer AboutWithAdvancedValue( not_null peer) { return AboutValue( peer ) | rpl::map([=](TextWithEntities &&value) { - if (!ShowPeerIdBelowAbout.value()) { - return std::move(value); + if (ShowPeerIdBelowAbout.value()) { + using namespace Ui::Text; + if (!value.empty()) { + value.append("\n\n"); + } + value.append(Italic(u"id: "_q)); + const auto raw = peer->id.value & PeerId::kChatTypeMask; + value.append(Link( + Italic(Lang::FormatCountDecimal(raw)), + "internal:~peer_id~:copy:" + QString::number(raw))); } - using namespace Ui::Text; - if (!value.empty()) { - value.append("\n\n"); + if (ShowChannelJoinedBelowAbout.value()) { + if (const auto channel = peer->asChannel()) { + if (!channel->amCreator() && channel->inviteDate) { + if (!value.empty()) { + if (ShowPeerIdBelowAbout.value()) { + value.append("\n"); + } else { + value.append("\n\n"); + } + } + using namespace Ui::Text; + value.append((channel->isMegagroup() + ? tr::lng_you_joined_group + : tr::lng_action_you_joined)( + tr::now, + Ui::Text::Italic)); + value.append(Italic(": ")); + const auto raw = channel->inviteDate; + value.append(Link( + Italic(langDateTimeFull(base::unixtime::parse(raw))), + "internal:~join_date~:show:" + QString::number(raw))); + } + } } - value.append(Italic(u"id: "_q)); - const auto raw = peer->id.value & PeerId::kChatTypeMask; - value.append(Link( - Italic(Lang::FormatCountDecimal(raw)), - "internal:~peer_id~:copy:" + QString::number(raw))); return std::move(value); }); } @@ -1178,6 +1207,23 @@ object_ptr DetailsFiller::setupInfo() { return false; } else if (SetClickContext(handler, context)) { return false; + } else if (handler->url().startsWith(u"internal:~join_date~:"_q)) { + const auto joinDate = handler->url().split( + u"show:"_q, + Qt::SkipEmptyParts).last(); + if (!joinDate.isEmpty()) { + const auto weak = base::make_weak(window); + window->session().api().resolveJumpToDate( + Dialogs::Key(peer->owner().history(peer)), + base::unixtime::parse(joinDate.toULongLong()).date(), + [=](not_null p, MsgId m) { + const auto f = Window::SectionShow::Way::Forward; + if (const auto strong = weak.get()) { + strong->showPeerHistory(p, f, m); + } + }); + return false; + } } else if (SetClickContext(handler, context)) { return false; } @@ -1386,8 +1432,8 @@ object_ptr DetailsFiller::setupInfo() { ? tr::lng_info_about_label() : tr::lng_info_bio_label(); addTranslateToMenu( - addInfoLine(std::move(label), AboutWithIdValue(user)).text, - AboutWithIdValue(user)); + addInfoLine(std::move(label), AboutWithAdvancedValue(user)).text, + AboutWithAdvancedValue(user)); const auto usernameLine = addInfoOneLine( UsernamesSubtext(_peer, tr::lng_info_username_label()), @@ -1517,9 +1563,9 @@ object_ptr DetailsFiller::setupInfo() { const auto about = addInfoLine(tr::lng_info_about_label(), _topic ? rpl::single(TextWithEntities()) - : AboutWithIdValue(_peer)); + : AboutWithAdvancedValue(_peer)); if (!_topic) { - addTranslateToMenu(about.text, AboutWithIdValue(_peer)); + addTranslateToMenu(about.text, AboutWithAdvancedValue(_peer)); } } if (!_peer->isSelf()) { @@ -2641,6 +2687,7 @@ object_ptr ActionsFiller::fill() { } // namespace const char kOptionShowPeerIdBelowAbout[] = "show-peer-id-below-about"; +const char kOptionShowChannelJoinedBelowAbout[] = "show-channel-joined-below-about"; object_ptr SetupDetails( not_null controller, diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.h b/Telegram/SourceFiles/info/profile/info_profile_actions.h index 078ce07204..584f2d7f86 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.h +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.h @@ -25,6 +25,7 @@ class Controller; namespace Info::Profile { extern const char kOptionShowPeerIdBelowAbout[]; +extern const char kOptionShowChannelJoinedBelowAbout[]; class Cover; struct Origin; diff --git a/Telegram/SourceFiles/settings/settings_experimental.cpp b/Telegram/SourceFiles/settings/settings_experimental.cpp index ef67935a64..7b04129a2a 100644 --- a/Telegram/SourceFiles/settings/settings_experimental.cpp +++ b/Telegram/SourceFiles/settings/settings_experimental.cpp @@ -147,6 +147,7 @@ void SetupExperimental( addToggle(Core::kOptionFractionalScalingEnabled); addToggle(Window::kOptionViewProfileInChatsListContextMenu); addToggle(Info::Profile::kOptionShowPeerIdBelowAbout); + addToggle(Info::Profile::kOptionShowChannelJoinedBelowAbout); addToggle(Ui::kOptionUseSmallMsgBubbleRadius); addToggle(Media::Player::kOptionDisableAutoplayNext); addToggle(kOptionSendLargePhotos);