From 4e11b0d241b915eae8058ca561400ee557241d83 Mon Sep 17 00:00:00 2001 From: sbertix Date: Sat, 22 May 2021 12:06:13 +0200 Subject: [PATCH 1/2] feat(endpoints): support delay between pages --- Package.swift | 2 +- .../Swiftagram/Endpoints/Recent/Endpoint+Recent.swift | 2 +- Tests/SwiftagramTests/EndpointTests.swift | 1 + docs/README.md | 9 ++++++--- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Package.swift b/Package.swift index 856478e9..2b113257 100644 --- a/Package.swift +++ b/Package.swift @@ -18,7 +18,7 @@ let package = Package( .library(name: "SwiftagramCrypto", targets: ["SwiftagramCrypto"])], // Package dependencies. - dependencies: [.package(url: "https://github.com/sbertix/ComposableRequest", .upToNextMinor(from: "5.1.0")), + dependencies: [.package(url: "https://github.com/sbertix/ComposableRequest", .upToNextMinor(from: "5.2.1")), .package(url: "https://github.com/sbertix/SwCrypt.git", .upToNextMinor(from: "5.1.0"))], // All targets. targets: [.target(name: "Swiftagram", diff --git a/Sources/Swiftagram/Endpoints/Recent/Endpoint+Recent.swift b/Sources/Swiftagram/Endpoints/Recent/Endpoint+Recent.swift index 2434bbfa..feced8bd 100644 --- a/Sources/Swiftagram/Endpoints/Recent/Endpoint+Recent.swift +++ b/Sources/Swiftagram/Endpoints/Recent/Endpoint+Recent.swift @@ -46,7 +46,7 @@ public extension Endpoint.Group.Recent { // Persist the rank token. let rank = pages.rank ?? UUID().uuidString // Prepare the actual pager. - return Pager(pages.count, offset: pages.offset.offset) { + return Pager(pages.count, offset: pages.offset.offset, delay: pages.delay) { Request.feed .path(appending: "timeline/") .header(appending: secret.header) diff --git a/Tests/SwiftagramTests/EndpointTests.swift b/Tests/SwiftagramTests/EndpointTests.swift index 9e1588d4..a5a51d3c 100644 --- a/Tests/SwiftagramTests/EndpointTests.swift +++ b/Tests/SwiftagramTests/EndpointTests.swift @@ -21,6 +21,7 @@ import AppKit @testable import Swiftagram @testable import SwiftagramCrypto +import ComposableRequest import SwCrypt /// The default delay. diff --git a/docs/README.md b/docs/README.md index 34ac717b..da3123c2 100644 --- a/docs/README.md +++ b/docs/README.md @@ -245,9 +245,12 @@ Endpoint.user(secret.identifier) .posts .unlock(with: secret) .session(.instagram) - .pages(.max) // Exhaust all with `.max` - // or pass any `Int` to limit - // pages. + .pages(.max, delay: 1) // Exhaust all with `.max` + // or pass any `Int` to limit + // pages. + // You can omit `delay`, in that + // case pages will be fetched + // one immediately after the other. .sink(receiveCompletion: { _ in }, receiveValue: { print($0) }) .store(in: &bin) ``` From f01680fe7a6488f97bb7bed270be56df28ec3765 Mon Sep 17 00:00:00 2001 From: sbertix Date: Sat, 22 May 2021 12:12:51 +0200 Subject: [PATCH 2/2] fix(examples): update `LoginViewController` access --- Examples/Authenticator/Authenticator/LoginView.swift | 2 +- Examples/Followers/Followers/LoginView.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/Authenticator/Authenticator/LoginView.swift b/Examples/Authenticator/Authenticator/LoginView.swift index 1b05244e..5502f13e 100644 --- a/Examples/Authenticator/Authenticator/LoginView.swift +++ b/Examples/Authenticator/Authenticator/LoginView.swift @@ -12,7 +12,7 @@ import WebKit import Swiftagram /// A `class` defining a view controller capable of displaying the authentication web view. -private class LoginViewController: UIViewController { +internal class LoginViewController: UIViewController { /// The completion handler. var completion: ((Secret) -> Void)? { didSet { diff --git a/Examples/Followers/Followers/LoginView.swift b/Examples/Followers/Followers/LoginView.swift index 534d9d62..dcdaaeb3 100644 --- a/Examples/Followers/Followers/LoginView.swift +++ b/Examples/Followers/Followers/LoginView.swift @@ -13,7 +13,7 @@ import Swiftagram import SwiftagramCrypto /// A `class` defining a view controller capable of displaying the authentication web view. -private class LoginViewController: UIViewController { +internal class LoginViewController: UIViewController { /// The completion handler. var completion: ((Secret) -> Void)? { didSet {