TheM4hd1 / SwiftyInsta

Instagram Private API Swift
MIT License
225 stars 51 forks source link

Fixed pagination support for Inbox #242

Closed mycroftcanner closed 3 years ago

sbertix commented 3 years ago
//
//  MessageHandler.swift
//  SwiftyInsta

Just remove all your edits, add the next parameter and it should all work fine. Please update this commit accordingly.

    /// Get the user's inbox.
    public func inbox(with paginationParameters: PaginationParameters,
                      updateHandler: PaginationUpdateHandler<Thread, AnyPaginatedResponse>?,
                      completionHandler: @escaping PaginationCompletionHandler<Thread>) {
        pages.request(Thread.self,
                      page: AnyPaginatedResponse.self,
                      with: paginationParameters,
                      endpoint: { Endpoint.Direct.inbox.next($0.nextMaxId) },
                      next: { $0.inbox.oldestCursor.string }, // Just add this line and it should all work.
                      splice: { $0.rawResponse.inbox.threads.array?.compactMap(Thread.init) ?? [] },
                      update: updateHandler,
                      completion: completionHandler)
    }