| 2359 | } |
| 2360 | |
| 2361 | std::optional<Stories::PeerSourceState> Stories::peerSourceState( |
| 2362 | not_null<PeerData*> peer, |
| 2363 | const MTPRecentStory &recent) { |
| 2364 | const auto &data = recent.data(); |
| 2365 | const auto maxId = data.vmax_id().value_or_empty(); |
| 2366 | const auto live = data.is_live(); |
| 2367 | const auto i = _readTill.find(peer->id); |
| 2368 | if (_readTillReceived || (i != end(_readTill))) { |
| 2369 | return PeerSourceState{ |
| 2370 | .maxId = maxId, |
| 2371 | .readTill = std::min( |
| 2372 | maxId, |
| 2373 | (i != end(_readTill)) ? i->second : 0), |
| 2374 | .hasVideoStream = live, |
| 2375 | }; |
| 2376 | } |
| 2377 | requestReadTills(); |
| 2378 | _pendingPeerRecentState[peer] = RecentState{ |
| 2379 | .maxId = maxId, |
| 2380 | .hasVideoStream = live, |
| 2381 | }; |
| 2382 | return std::nullopt; |
| 2383 | } |
| 2384 | |
| 2385 | void Stories::requestReadTills() { |
| 2386 | if (_readTillReceived || _readTillsRequestId) { |
no test coverage detected