mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-13 23:13:32 +00:00
Show community status across ordinary peer lists
Task: 2026/07/23/show-community-status-in-peer-lists
This commit is contained in:
@@ -31,7 +31,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#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"
|
||||
@@ -747,11 +746,7 @@ void PeerListRow::refreshStatus() {
|
||||
setStatusText(tr::lng_group_status(tr::now));
|
||||
} else if (const auto channel = peer()->asChannel()) {
|
||||
if (channel->isCommunity()) {
|
||||
const auto info = channel->communityInfo();
|
||||
const auto count = info ? int(info->histories().size()) : 0;
|
||||
setStatusText(count
|
||||
? tr::lng_community_chats(tr::now, lt_count, count)
|
||||
: tr::lng_community_status(tr::now));
|
||||
setStatusText(tr::lng_community_status(tr::now));
|
||||
} else {
|
||||
setStatusText(tr::lng_channel_status(tr::now));
|
||||
}
|
||||
|
||||
@@ -1056,6 +1056,12 @@ auto ChooseRecipientBoxController::createRow(
|
||||
auto result = std::make_unique<Row>(
|
||||
history,
|
||||
_moneyRestrictionError ? &computeListSt().item : nullptr);
|
||||
if (const auto info = JoinedCommunityChats(peer)) {
|
||||
result->setCustomStatus(tr::lng_community_chats(
|
||||
tr::now,
|
||||
lt_count,
|
||||
int(info->histories().size())));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "apiwrap.h"
|
||||
#include "boxes/peer_list_box.h"
|
||||
#include "boxes/peers/manage_community_box.h"
|
||||
#include "data/data_changes.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_community.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_session.h"
|
||||
#include "lang/lang_hardcoded.h"
|
||||
@@ -55,7 +53,6 @@ public:
|
||||
|
||||
private:
|
||||
void appendRow(not_null<ChannelData*> community);
|
||||
void updateStatus(not_null<PeerListRow*> row);
|
||||
|
||||
const not_null<PeerData*> _peer;
|
||||
const Fn<void(not_null<ChannelData*>)> _callback;
|
||||
@@ -75,16 +72,6 @@ Main::Session &Controller::session() const {
|
||||
}
|
||||
|
||||
void Controller::prepare() {
|
||||
session().changes().peerUpdates(
|
||||
Data::PeerUpdate::Flag::FullInfo
|
||||
) | rpl::on_next([=](const Data::PeerUpdate &update) {
|
||||
if (const auto row = delegate()->peerListFindRow(
|
||||
update.peer->id.value)) {
|
||||
updateStatus(row);
|
||||
delegate()->peerListUpdateRow(row);
|
||||
}
|
||||
}, lifetime());
|
||||
|
||||
session().api().communities().requestJoinedCommunities(crl::guard(
|
||||
this,
|
||||
[=](const std::vector<not_null<ChannelData*>> &list) {
|
||||
@@ -107,20 +94,7 @@ void Controller::appendRow(not_null<ChannelData*> community) {
|
||||
return;
|
||||
}
|
||||
auto row = std::make_unique<PeerListRow>(community);
|
||||
updateStatus(row.get());
|
||||
delegate()->peerListAppendRow(std::move(row));
|
||||
if (!community->wasFullUpdated()) {
|
||||
session().api().requestFullPeer(community);
|
||||
}
|
||||
}
|
||||
|
||||
void Controller::updateStatus(not_null<PeerListRow*> row) {
|
||||
const auto community = row->peer()->asChannel();
|
||||
const auto info = community ? community->communityInfo() : nullptr;
|
||||
const auto count = info ? int(info->linkedPeers().size()) : 0;
|
||||
row->setCustomStatus(count
|
||||
? tr::lng_community_chats(tr::now, lt_count, count)
|
||||
: tr::lng_community_status(tr::now));
|
||||
}
|
||||
|
||||
void CreateCommunityBox(
|
||||
|
||||
@@ -266,7 +266,7 @@ RecentRow::RecentRow(not_null<PeerData*> peer)
|
||||
chat->count));
|
||||
}
|
||||
} else if (const auto channel = peer->asChannel()) {
|
||||
if (channel->membersCountKnown()) {
|
||||
if (!channel->isCommunity() && channel->membersCountKnown()) {
|
||||
setCustomStatus((channel->isBroadcast()
|
||||
? tr::lng_chat_status_subscribers
|
||||
: tr::lng_chat_status_members)(
|
||||
|
||||
Reference in New Issue
Block a user