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:
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user