mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Allow paid reaction even after limit is reached.
This commit is contained in:
parent
284f1a5210
commit
0a1ddddd81
4 changed files with 10 additions and 5 deletions
|
@ -966,7 +966,8 @@ void ChannelData::setAllowedReactions(Data::AllowedReactions value) {
|
||||||
if (_allowedReactions != value) {
|
if (_allowedReactions != value) {
|
||||||
const auto enabled = [](const Data::AllowedReactions &allowed) {
|
const auto enabled = [](const Data::AllowedReactions &allowed) {
|
||||||
return (allowed.type != Data::AllowedReactionsType::Some)
|
return (allowed.type != Data::AllowedReactionsType::Some)
|
||||||
|| !allowed.some.empty();
|
|| !allowed.some.empty()
|
||||||
|
|| allowed.paidEnabled;
|
||||||
};
|
};
|
||||||
const auto was = enabled(_allowedReactions);
|
const auto was = enabled(_allowedReactions);
|
||||||
_allowedReactions = std::move(value);
|
_allowedReactions = std::move(value);
|
||||||
|
|
|
@ -293,7 +293,8 @@ void ChatData::setAllowedReactions(Data::AllowedReactions value) {
|
||||||
if (_allowedReactions != value) {
|
if (_allowedReactions != value) {
|
||||||
const auto enabled = [](const Data::AllowedReactions &allowed) {
|
const auto enabled = [](const Data::AllowedReactions &allowed) {
|
||||||
return (allowed.type != Data::AllowedReactionsType::Some)
|
return (allowed.type != Data::AllowedReactionsType::Some)
|
||||||
|| !allowed.some.empty();
|
|| !allowed.some.empty()
|
||||||
|
|| allowed.paidEnabled;
|
||||||
};
|
};
|
||||||
const auto was = enabled(_allowedReactions);
|
const auto was = enabled(_allowedReactions);
|
||||||
_allowedReactions = std::move(value);
|
_allowedReactions = std::move(value);
|
||||||
|
|
|
@ -177,6 +177,7 @@ PossibleItemReactionsRef LookupPossibleReactions(
|
||||||
const auto &myTags = reactions->list(Reactions::Type::MyTags);
|
const auto &myTags = reactions->list(Reactions::Type::MyTags);
|
||||||
const auto &tags = reactions->list(Reactions::Type::Tags);
|
const auto &tags = reactions->list(Reactions::Type::Tags);
|
||||||
const auto &all = item->reactions();
|
const auto &all = item->reactions();
|
||||||
|
const auto &allowed = PeerAllowedReactions(peer);
|
||||||
const auto limit = UniqueReactionsLimit(peer);
|
const auto limit = UniqueReactionsLimit(peer);
|
||||||
const auto premiumPossible = session->premiumPossible();
|
const auto premiumPossible = session->premiumPossible();
|
||||||
const auto limited = (all.size() >= limit) && [&] {
|
const auto limited = (all.size() >= limit) && [&] {
|
||||||
|
@ -212,7 +213,10 @@ PossibleItemReactionsRef LookupPossibleReactions(
|
||||||
result.customAllowed = premiumPossible;
|
result.customAllowed = premiumPossible;
|
||||||
result.tags = true;
|
result.tags = true;
|
||||||
} else if (limited) {
|
} 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) {
|
add([&](const Reaction &reaction) {
|
||||||
return ranges::contains(all, reaction.id, &MessageReaction::id);
|
return ranges::contains(all, reaction.id, &MessageReaction::id);
|
||||||
});
|
});
|
||||||
|
@ -225,7 +229,6 @@ PossibleItemReactionsRef LookupPossibleReactions(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const auto &allowed = PeerAllowedReactions(peer);
|
|
||||||
result.recent.reserve((allowed.paidEnabled ? 1 : 0)
|
result.recent.reserve((allowed.paidEnabled ? 1 : 0)
|
||||||
+ ((allowed.type == AllowedReactionsType::Some)
|
+ ((allowed.type == AllowedReactionsType::Some)
|
||||||
? allowed.some.size()
|
? allowed.some.size()
|
||||||
|
|
|
@ -2572,7 +2572,7 @@ void HistoryItem::toggleReaction(
|
||||||
_reactions->add(reaction, addToRecent);
|
_reactions->add(reaction, addToRecent);
|
||||||
} else if (ranges::contains(_reactions->chosen(), reaction)) {
|
} else if (ranges::contains(_reactions->chosen(), reaction)) {
|
||||||
_reactions->remove(reaction);
|
_reactions->remove(reaction);
|
||||||
if (_reactions->empty()) {
|
if (_reactions->empty() && !_reactions->localPaidData()) {
|
||||||
_reactions = nullptr;
|
_reactions = nullptr;
|
||||||
_flags &= ~MessageFlag::CanViewReactions;
|
_flags &= ~MessageFlag::CanViewReactions;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue