MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / requestUserpics

Method requestUserpics

Telegram/SourceFiles/export/export_api_wrap.cpp:818–851  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

816}
817
818void ApiWrap::requestUserpics(
819 FnMut<bool(Data::UserpicsInfo&&)> start,
820 Fn<bool(DownloadProgress)> progress,
821 Fn<bool(Data::UserpicsSlice&&)> slice,
822 FnMut<void()> finish) {
823 Expects(_userpicsProcess == nullptr);
824
825 _userpicsProcess = std::make_unique<UserpicsProcess>();
826 _userpicsProcess->start = std::move(start);
827 _userpicsProcess->fileProgress = std::move(progress);
828 _userpicsProcess->handleSlice = std::move(slice);
829 _userpicsProcess->finish = std::move(finish);
830
831 mainRequest(MTPphotos_GetUserPhotos(
832 _user,
833 MTP_int(0), // offset
834 MTP_long(_userpicsProcess->maxId),
835 MTP_int(kUserpicsSliceLimit)
836 )).done([=](const MTPphotos_Photos &result) mutable {
837 Expects(_userpicsProcess != nullptr);
838
839 auto startInfo = result.match(
840 [](const MTPDphotos_photos &data) {
841 return Data::UserpicsInfo{ int(data.vphotos().v.size()) };
842 }, [](const MTPDphotos_photosSlice &data) {
843 return Data::UserpicsInfo{ data.vcount().v };
844 });
845 if (!_userpicsProcess->start(std::move(startInfo))) {
846 return;
847 }
848
849 handleUserpicsSlice(result);
850 }).send();
851}
852
853void ApiWrap::handleUserpicsSlice(const MTPphotos_Photos &result) {
854 Expects(_userpicsProcess != nullptr);

Callers 1

exportUserpicsMethod · 0.80

Calls 6

MTP_longFunction · 0.85
MTP_intFunction · 0.50
sendMethod · 0.45
doneMethod · 0.45
sizeMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected