| 386 | } |
| 387 | |
| 388 | void Updates::channelDifferenceDone( |
| 389 | not_null<ChannelData*> channel, |
| 390 | const MTPupdates_ChannelDifference &difference) { |
| 391 | _channelFailDifferenceTimeout.remove(channel); |
| 392 | |
| 393 | const auto timeout = difference.match([&](const auto &data) { |
| 394 | return data.vtimeout().value_or_empty(); |
| 395 | }); |
| 396 | const auto isFinal = difference.match([&](const auto &data) { |
| 397 | return data.is_final(); |
| 398 | }); |
| 399 | difference.match([&](const MTPDupdates_channelDifferenceEmpty &data) { |
| 400 | channel->ptsInit(data.vpts().v); |
| 401 | }, [&](const MTPDupdates_channelDifferenceTooLong &data) { |
| 402 | session().data().processUsers(data.vusers()); |
| 403 | session().data().processChats(data.vchats()); |
| 404 | const auto history = session().data().historyLoaded(channel->id); |
| 405 | if (history) { |
| 406 | history->setNotLoadedAtBottom(); |
| 407 | requestChannelRangeDifference(history); |
| 408 | } |
| 409 | data.vdialog().match([&](const MTPDdialog &data) { |
| 410 | if (const auto pts = data.vpts()) { |
| 411 | channel->ptsInit(pts->v); |
| 412 | } |
| 413 | }, [&](const MTPDdialogFolder &) { |
| 414 | }); |
| 415 | session().data().applyDialogs( |
| 416 | nullptr, |
| 417 | data.vmessages().v, |
| 418 | QVector<MTPDialog>(1, data.vdialog())); |
| 419 | session().data().channelDifferenceTooLong(channel); |
| 420 | if (const auto forum = channel->forum()) { |
| 421 | forum->reloadTopics(); |
| 422 | } |
| 423 | }, [&](const MTPDupdates_channelDifference &data) { |
| 424 | feedChannelDifference(data); |
| 425 | channel->ptsInit(data.vpts().v); |
| 426 | }); |
| 427 | |
| 428 | channel->ptsSetRequesting(false); |
| 429 | |
| 430 | if (!isFinal) { |
| 431 | MTP_LOG(0, ("getChannelDifference " |
| 432 | "{ good - after not final channelDifference was received }%1" |
| 433 | ).arg(_session->mtp().isTestMode() ? " TESTMODE" : "")); |
| 434 | getChannelDifference(channel); |
| 435 | } else if (inActiveChats(channel)) { |
| 436 | channel->ptsSetWaitingForShortPoll(timeout |
| 437 | ? (timeout * crl::time(1000)) |
| 438 | : kWaitForChannelGetDifference); |
| 439 | } else { |
| 440 | channel->ptsSetWaitingForShortPoll(-1); |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | void Updates::feedChannelDifference( |
| 445 | const MTPDupdates_channelDifference &data) { |
nothing calls this directly
no test coverage detected