| 960 | } |
| 961 | |
| 962 | void ApiWrap::requestStories( |
| 963 | FnMut<bool(Data::StoriesInfo&&)> start, |
| 964 | Fn<bool(DownloadProgress)> progress, |
| 965 | Fn<bool(Data::StoriesSlice&&)> slice, |
| 966 | FnMut<void()> finish) { |
| 967 | Expects(_storiesProcess == nullptr); |
| 968 | |
| 969 | _storiesProcess = std::make_unique<StoriesProcess>(); |
| 970 | _storiesProcess->start = std::move(start); |
| 971 | _storiesProcess->fileProgress = std::move(progress); |
| 972 | _storiesProcess->handleSlice = std::move(slice); |
| 973 | _storiesProcess->finish = std::move(finish); |
| 974 | |
| 975 | mainRequest(MTPstories_GetStoriesArchive( |
| 976 | MTP_inputPeerSelf(), |
| 977 | MTP_int(_storiesProcess->offsetId), |
| 978 | MTP_int(kStoriesSliceLimit) |
| 979 | )).done([=](const MTPstories_Stories &result) mutable { |
| 980 | Expects(_storiesProcess != nullptr); |
| 981 | |
| 982 | auto startInfo = Data::StoriesInfo{ result.data().vcount().v }; |
| 983 | if (!_storiesProcess->start(std::move(startInfo))) { |
| 984 | return; |
| 985 | } |
| 986 | |
| 987 | handleStoriesSlice(result); |
| 988 | }).send(); |
| 989 | } |
| 990 | |
| 991 | void ApiWrap::handleStoriesSlice(const MTPstories_Stories &result) { |
| 992 | Expects(_storiesProcess != nullptr); |