diff --git a/Telegram/SourceFiles/boxes/peers/peer_short_info_box.cpp b/Telegram/SourceFiles/boxes/peers/peer_short_info_box.cpp index ff486ead9..dc7524e76 100644 --- a/Telegram/SourceFiles/boxes/peers/peer_short_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/peer_short_info_box.cpp @@ -775,6 +775,10 @@ void PeerShortInfoBox::prepareRows() { result->setContextCopyText(contextCopyText); return result; }; + addInfoOneLine( + tr::lng_settings_channel_label(), + channelValue(), + tr::lng_context_copy_link(tr::now)); addInfoOneLine( tr::lng_info_link_label(), linkValue(), @@ -836,6 +840,13 @@ rpl::producer PeerShortInfoBox::nameValue() const { }) | rpl::distinct_until_changed(); } +rpl::producer PeerShortInfoBox::channelValue() const { + return _fields.value( + ) | rpl::map([](const PeerShortInfoFields &fields) { + return Ui::Text::Link(fields.channelName, fields.channelLink); + }) | rpl::distinct_until_changed(); +} + rpl::producer PeerShortInfoBox::linkValue() const { return _fields.value( ) | rpl::map([](const PeerShortInfoFields &fields) { diff --git a/Telegram/SourceFiles/boxes/peers/peer_short_info_box.h b/Telegram/SourceFiles/boxes/peers/peer_short_info_box.h index cda68a99b..b51ac3e2d 100644 --- a/Telegram/SourceFiles/boxes/peers/peer_short_info_box.h +++ b/Telegram/SourceFiles/boxes/peers/peer_short_info_box.h @@ -37,6 +37,8 @@ enum class PeerShortInfoType { struct PeerShortInfoFields { QString name; + QString channelName; + QString channelLink; QString phone; QString link; TextWithEntities about; @@ -169,6 +171,7 @@ private: int fillRoundedTopHeight(); [[nodiscard]] rpl::producer nameValue() const; + [[nodiscard]] rpl::producer channelValue() const; [[nodiscard]] rpl::producer linkValue() const; [[nodiscard]] rpl::producer phoneValue() const; [[nodiscard]] rpl::producer usernameValue() const; diff --git a/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp b/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp index 363a2e9dc..c3ff09a68 100644 --- a/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp @@ -202,6 +202,7 @@ void ProcessFullPhoto( return peer->session().changes().peerFlagsValue( peer, (UpdateFlag::Name + | UpdateFlag::PersonalChannel | UpdateFlag::PhoneNumber | UpdateFlag::Username | UpdateFlag::About @@ -209,8 +210,20 @@ void ProcessFullPhoto( ) | rpl::map([=] { const auto user = peer->asUser(); const auto username = peer->username(); + const auto channelId = user->personalChannelId(); + const auto channel = channelId + ? user->owner().channel(channelId).get() + : nullptr; + const auto channelUsername = channel + ? channel->username() + : QString(); + const auto hasChannel = !channelUsername.isEmpty(); return PeerShortInfoFields{ .name = peer->name(), + .channelName = hasChannel ? channel->name() : QString(), + .channelLink = (hasChannel + ? channel->session().createInternalLinkFull(channelUsername) + : QString()), .phone = user ? Ui::FormatPhone(user->phone()) : QString(), .link = ((user || username.isEmpty()) ? QString()