From d1a211a080d46e4a32a41232be3a047ab09b5f28 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 17 Jul 2026 15:28:24 +0400 Subject: [PATCH] Show community chats count and effect in peer lists. --- Telegram/SourceFiles/boxes/peer_list_box.cpp | 41 +++++++++++++++++++- Telegram/SourceFiles/boxes/peer_list_box.h | 2 + 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 1377a2e726..30a751eb7a 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -29,7 +29,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "storage/file_download.h" #include "data/data_peer_values.h" +#include "data/data_channel.h" #include "data/data_chat.h" +#include "data/data_community.h" #include "data/data_session.h" #include "data/data_changes.h" #include "data/stickers/data_custom_emoji.h" @@ -743,8 +745,23 @@ void PeerListRow::refreshStatus() { } } else if (peer()->isMegagroup()) { setStatusText(tr::lng_group_status(tr::now)); - } else if (peer()->isChannel()) { - setStatusText(tr::lng_channel_status(tr::now)); + } else if (const auto channel = peer()->asChannel()) { + if (channel->isCommunity()) { + const auto info = channel->communityInfo(); + auto count = 0; + if (info) { + for (const auto &linked : info->linkedPeers()) { + if (Data::CommunityChatJoined(linked.peer)) { + ++count; + } + } + } + setStatusText(count + ? tr::lng_community_chats(tr::now, lt_count, count) + : tr::lng_community_status(tr::now)); + } else { + setStatusText(tr::lng_channel_status(tr::now)); + } } } @@ -1039,6 +1056,21 @@ void PeerListRow::paintUserpic( int x, int y, int outerWidth) { + if (paintCommunityUserpicEffect()) { + if (!_communityUserpicEffect) { + _communityUserpicEffect + = std::make_unique(); + } + Ui::PaintCommunityUserpicEffect( + p, + *_communityUserpicEffect, + x, + y, + st.photoSize, + st::windowSubTextFg->c); + } else if (_communityUserpicEffect) { + _communityUserpicEffect = nullptr; + } if (_disabledState == State::DisabledChecked) { paintDisabledCheckUserpic(p, st, x, y, outerWidth); } else if (_checkbox) { @@ -1124,6 +1156,11 @@ bool PeerListRow::useForumLikeUserpic() const { return !special() && peer()->isForum(); } +bool PeerListRow::paintCommunityUserpicEffect() const { + const auto channel = special() ? nullptr : peer()->asChannel(); + return channel && channel->isCommunity(); +} + void PeerListRow::createCheckbox( const style::RoundImageCheckbox &st, Fn updateCallback) { diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index 26a7de83b6..eee902d03f 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -200,6 +200,7 @@ public: } virtual bool useForumLikeUserpic() const; + [[nodiscard]] virtual bool paintCommunityUserpicEffect() const; enum class StatusType { Online, @@ -333,6 +334,7 @@ private: std::pair _userpicKey; std::unique_ptr _ripple; std::unique_ptr _checkbox; + std::unique_ptr _communityUserpicEffect; Ui::Text::String _name; Ui::Text::String _status; Ui::PeerBadge _badge;