| 1521 | } |
| 1522 | |
| 1523 | void Reactions::poll(not_null<HistoryItem*> item, crl::time now) { |
| 1524 | // Group them by one second. |
| 1525 | const auto last = item->lastReactionsRefreshTime(); |
| 1526 | const auto grouped = ((last + 999) / 1000) * 1000; |
| 1527 | if (!grouped || item->history()->peer->isUser()) { |
| 1528 | // First reaction always edits message. |
| 1529 | return; |
| 1530 | } else if (const auto left = grouped + kPollEach - now; left > 0) { |
| 1531 | if (!_repaintItems.contains(item)) { |
| 1532 | _repaintItems.emplace(item, grouped + kPollEach); |
| 1533 | if (!_repaintTimer.isActive() |
| 1534 | || _repaintTimer.remainingTime() > left) { |
| 1535 | _repaintTimer.callOnce(left); |
| 1536 | } |
| 1537 | } |
| 1538 | } else if (!_pollingItems.contains(item)) { |
| 1539 | if (_pollItems.empty() && !_pollRequestId) { |
| 1540 | crl::on_main(&_owner->session(), [=] { |
| 1541 | pollCollected(); |
| 1542 | }); |
| 1543 | } |
| 1544 | _pollItems.emplace(item); |
| 1545 | } |
| 1546 | } |
| 1547 | |
| 1548 | void Reactions::updateAllInHistory(not_null<PeerData*> peer, bool enabled) { |
| 1549 | if (const auto history = _owner->historyLoaded(peer)) { |