2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

Implement PoC custom reaction selection.

This commit is contained in:
John Preston
2022-08-16 18:52:49 +03:00
parent cece9cf09b
commit 09124f6424
24 changed files with 449 additions and 152 deletions

View File

@@ -513,25 +513,23 @@ rpl::producer<QImage> PeerUserpicImageValue(
};
}
std::optional<base::flat_set<QString>> PeerAllowedReactions(
not_null<PeerData*> peer) {
ReactionsFilter PeerReactionsFilter(not_null<PeerData*> peer) {
if (const auto chat = peer->asChat()) {
return chat->allowedReactions();
return { .allowed = chat->allowedReactions() };
} else if (const auto channel = peer->asChannel()) {
return channel->allowedReactions();
return { .allowed = channel->allowedReactions() };
} else {
return std::nullopt;
return { .customAllowed = true };
}
}
auto PeerAllowedReactionsValue(
not_null<PeerData*> peer)
-> rpl::producer<std::optional<base::flat_set<QString>>> {
rpl::producer<ReactionsFilter> PeerReactionsFilterValue(
not_null<PeerData*> peer) {
return peer->session().changes().peerFlagsValue(
peer,
Data::PeerUpdate::Flag::Reactions
) | rpl::map([=]{
return PeerAllowedReactions(peer);
return PeerReactionsFilter(peer);
});
}