Allow paid reaction even after limit is reached.

This commit is contained in:
John Preston 2024-08-13 08:42:28 +02:00
parent 284f1a5210
commit 0a1ddddd81
4 changed files with 10 additions and 5 deletions

View file

@ -966,7 +966,8 @@ void ChannelData::setAllowedReactions(Data::AllowedReactions value) {
if (_allowedReactions != value) {
const auto enabled = [](const Data::AllowedReactions &allowed) {
return (allowed.type != Data::AllowedReactionsType::Some)
|| !allowed.some.empty();
|| !allowed.some.empty()
|| allowed.paidEnabled;
};
const auto was = enabled(_allowedReactions);
_allowedReactions = std::move(value);

View file

@ -293,7 +293,8 @@ void ChatData::setAllowedReactions(Data::AllowedReactions value) {
if (_allowedReactions != value) {
const auto enabled = [](const Data::AllowedReactions &allowed) {
return (allowed.type != Data::AllowedReactionsType::Some)
|| !allowed.some.empty();
|| !allowed.some.empty()
|| allowed.paidEnabled;
};
const auto was = enabled(_allowedReactions);
_allowedReactions = std::move(value);

View file

@ -177,6 +177,7 @@ PossibleItemReactionsRef LookupPossibleReactions(
const auto &myTags = reactions->list(Reactions::Type::MyTags);
const auto &tags = reactions->list(Reactions::Type::Tags);
const auto &all = item->reactions();
const auto &allowed = PeerAllowedReactions(peer);
const auto limit = UniqueReactionsLimit(peer);
const auto premiumPossible = session->premiumPossible();
const auto limited = (all.size() >= limit) && [&] {
@ -212,7 +213,10 @@ PossibleItemReactionsRef LookupPossibleReactions(
result.customAllowed = premiumPossible;
result.tags = true;
} else if (limited) {
result.recent.reserve(all.size());
result.recent.reserve((allowed.paidEnabled ? 1 : 0) + all.size());
if (allowed.paidEnabled) {
result.recent.push_back(reactions->lookupPaid());
}
add([&](const Reaction &reaction) {
return ranges::contains(all, reaction.id, &MessageReaction::id);
});
@ -225,7 +229,6 @@ PossibleItemReactionsRef LookupPossibleReactions(
}
}
} else {
const auto &allowed = PeerAllowedReactions(peer);
result.recent.reserve((allowed.paidEnabled ? 1 : 0)
+ ((allowed.type == AllowedReactionsType::Some)
? allowed.some.size()

View file

@ -2572,7 +2572,7 @@ void HistoryItem::toggleReaction(
_reactions->add(reaction, addToRecent);
} else if (ranges::contains(_reactions->chosen(), reaction)) {
_reactions->remove(reaction);
if (_reactions->empty()) {
if (_reactions->empty() && !_reactions->localPaidData()) {
_reactions = nullptr;
_flags &= ~MessageFlag::CanViewReactions;
}