| 402 | } |
| 403 | |
| 404 | void GroupCall::enqueueUpdate(const MTPUpdate &update) { |
| 405 | const auto initial = !_version; |
| 406 | update.match([&](const MTPDupdateGroupCall &updateData) { |
| 407 | updateData.vcall().match([&](const MTPDgroupCall &data) { |
| 408 | const auto version = data.vversion().v; |
| 409 | if (!_applyingQueuedUpdates |
| 410 | && (!_version || _version == version)) { |
| 411 | DEBUG_LOG(("Group Call Participants: " |
| 412 | "Apply updateGroupCall %1 -> %2" |
| 413 | ).arg(_version |
| 414 | ).arg(version)); |
| 415 | applyEnqueuedUpdate(update); |
| 416 | } else if (!_version || _version <= version) { |
| 417 | DEBUG_LOG(("Group Call Participants: " |
| 418 | "Queue updateGroupCall %1 -> %2" |
| 419 | ).arg(_version |
| 420 | ).arg(version)); |
| 421 | const auto type = QueuedType::Call; |
| 422 | _queuedUpdates.emplace(std::pair{ version, type }, update); |
| 423 | } |
| 424 | }, [&](const MTPDgroupCallDiscarded &data) { |
| 425 | discard(data); |
| 426 | }); |
| 427 | }, [&](const MTPDupdateGroupCallParticipants &updateData) { |
| 428 | const auto version = updateData.vversion().v; |
| 429 | const auto proj = [](const MTPGroupCallParticipant &data) { |
| 430 | return data.match([&](const MTPDgroupCallParticipant &data) { |
| 431 | return data.is_versioned(); |
| 432 | }); |
| 433 | }; |
| 434 | const auto increment = ranges::contains( |
| 435 | updateData.vparticipants().v, |
| 436 | true, |
| 437 | proj); |
| 438 | const auto required = increment ? (version - 1) : version; |
| 439 | if (!_applyingQueuedUpdates && (_version == required)) { |
| 440 | DEBUG_LOG(("Group Call Participants: " |
| 441 | "Apply updateGroupCallParticipant %1 (%2)" |
| 442 | ).arg(_version |
| 443 | ).arg(Logs::b(increment))); |
| 444 | applyEnqueuedUpdate(update); |
| 445 | } else if (_version <= required) { |
| 446 | DEBUG_LOG(("Group Call Participants: " |
| 447 | "Queue updateGroupCallParticipant %1 -> %2 (%3)" |
| 448 | ).arg(_version |
| 449 | ).arg(version |
| 450 | ).arg(Logs::b(increment))); |
| 451 | const auto type = increment |
| 452 | ? QueuedType::VersionedParticipant |
| 453 | : QueuedType::Participant; |
| 454 | _queuedUpdates.emplace(std::pair{ version, type }, update); |
| 455 | } |
| 456 | }, [](const auto &) { |
| 457 | Unexpected("Type in GroupCall::enqueueUpdate."); |
| 458 | }); |
| 459 | processQueuedUpdates(initial); |
| 460 | } |
| 461 |
no test coverage detected