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

Start paid reaction toast notification.

This commit is contained in:
John Preston
2024-08-08 10:56:31 +02:00
parent 02610de010
commit ac92e1c99e
19 changed files with 371 additions and 6 deletions

View File

@@ -48,7 +48,7 @@ constexpr auto kRecentReactionsLimit = 40;
constexpr auto kMyTagsRequestTimeout = crl::time(1000);
constexpr auto kTopRequestDelay = 60 * crl::time(1000);
constexpr auto kTopReactionsLimit = 14;
constexpr auto kPaidAccumulatePeriod = 5 * crl::time(1000);
constexpr auto kPaidAccumulatePeriod = 5 * crl::time(1000) + 500;
[[nodiscard]] QString ReactionIdToLog(const ReactionId &id) {
if (const auto custom = id.custom()) {
@@ -1525,6 +1525,15 @@ not_null<Reaction*> Reactions::lookupPaid() {
return &*_paid;
}
not_null<DocumentData*> Reactions::paidToastAnimation() {
if (!_paidToastAnimation) {
_paidToastAnimation = ChatHelpers::GenerateLocalTgsSticker(
&_owner->session(),
u"star_reaction_toast"_q);
}
return _paidToastAnimation;
}
rpl::producer<std::vector<Reaction>> Reactions::myTagsValue(
SavedSublist *sublist) {
refreshMyTags(sublist);
@@ -1546,6 +1555,21 @@ void Reactions::schedulePaid(not_null<HistoryItem*> item) {
}
}
void Reactions::undoScheduledPaid(not_null<HistoryItem*> item) {
_sendPaidItems.remove(item);
item->cancelScheduledPaidReaction();
}
crl::time Reactions::sendingScheduledPaidAt(
not_null<HistoryItem*> item) const {
const auto i = _sendPaidItems.find(item);
return (i != end(_sendPaidItems)) ? i->second : crl::time();
}
crl::time Reactions::ScheduledPaidDelay() {
return kPaidAccumulatePeriod;
}
void Reactions::repaintCollected() {
const auto now = crl::now();
auto closest = crl::time();