2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Show emoji statuses in channels.

This commit is contained in:
John Preston
2023-12-16 22:43:35 +00:00
parent 6aaf841a73
commit 805a5d73b6
12 changed files with 81 additions and 67 deletions

View File

@@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_peer.h"
#include "data/data_session.h"
#include "data/data_user.h"
#include "data/stickers/data_custom_emoji.h"
#include "info/profile/info_profile_values.h"
#include "info/profile/info_profile_emoji_status_panel.h"
@@ -24,10 +25,16 @@ namespace {
[[nodiscard]] rpl::producer<Badge::Content> ContentForPeer(
not_null<PeerData*> peer) {
const auto statusOnlyForPremium = peer->isUser();
return rpl::combine(
BadgeValue(peer),
EmojiStatusIdValue(peer)
) | rpl::map([=](BadgeType badge, DocumentId emojiStatusId) {
if (statusOnlyForPremium) {
emojiStatusId = 0;
} else if (emojiStatusId && badge == BadgeType::None) {
badge = BadgeType::Premium;
}
return Badge::Content{ badge, emojiStatusId };
});
}
@@ -91,9 +98,6 @@ void Badge::setContent(Content content) {
if (!(_allowed & content.badge)) {
content.badge = BadgeType::None;
}
if (content.badge != BadgeType::Premium) {
content.emojiStatusId = 0;
}
if (_content == content) {
return;
}

View File

@@ -609,15 +609,14 @@ rpl::producer<BadgeType> BadgeValue(not_null<PeerData*> peer) {
}
rpl::producer<DocumentId> EmojiStatusIdValue(not_null<PeerData*> peer) {
if (const auto user = peer->asUser()) {
return user->session().changes().peerFlagsValue(
peer,
Data::PeerUpdate::Flag::EmojiStatus
) | rpl::map([=] { return user->emojiStatusId(); });
if (peer->isChat()) {
return rpl::single(DocumentId(0));
}
return rpl::single(DocumentId(0));
return peer->session().changes().peerFlagsValue(
peer,
Data::PeerUpdate::Flag::EmojiStatus
) | rpl::map([=] { return peer->emojiStatusId(); });
}
} // namespace Profile
} // namespace Info