Show community chats count and effect in peer lists.

This commit is contained in:
John Preston
2026-07-17 15:28:24 +04:00
parent f11a3d44d9
commit d1a211a080
2 changed files with 41 additions and 2 deletions
+39 -2
View File
@@ -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::CommunityUserpicEffect>();
}
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<void()> updateCallback) {
@@ -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<uint64, uint64> _userpicKey;
std::unique_ptr<Ui::RippleAnimation> _ripple;
std::unique_ptr<Ui::RoundImageCheckbox> _checkbox;
std::unique_ptr<Ui::CommunityUserpicEffect> _communityUserpicEffect;
Ui::Text::String _name;
Ui::Text::String _status;
Ui::PeerBadge _badge;