| 816 | } |
| 817 | |
| 818 | void 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 | |
| 853 | void ApiWrap::handleUserpicsSlice(const MTPphotos_Photos &result) { |
| 854 | Expects(_userpicsProcess != nullptr); |