From 912a3acb3503b61fce13401531c08ea05e5c9c0e Mon Sep 17 00:00:00 2001 From: Kiel Gillard Date: Fri, 17 Jan 2020 17:16:52 +1100 Subject: [PATCH] Subscribing to a Feedly feed only downloads the first page worth of content, not each and every page. Maybe related to #1408. --- .../FeedlySyncStreamContentsOperationTests.swift | 6 +++--- .../Operations/FeedlyAddNewFeedOperation.swift | 12 ++++++------ .../FeedlySyncStreamContentsOperation.swift | 8 +++++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Frameworks/Account/AccountTests/Feedly/FeedlySyncStreamContentsOperationTests.swift b/Frameworks/Account/AccountTests/Feedly/FeedlySyncStreamContentsOperationTests.swift index f4358b79a..897d7492c 100644 --- a/Frameworks/Account/AccountTests/Feedly/FeedlySyncStreamContentsOperationTests.swift +++ b/Frameworks/Account/AccountTests/Feedly/FeedlySyncStreamContentsOperationTests.swift @@ -45,7 +45,7 @@ class FeedlySyncStreamContentsOperationTests: XCTestCase { XCTAssertNil(serviceUnreadOnly) } - let syncStreamContents = FeedlySyncStreamContentsOperation(account: account, resource: resource, service: service, newerThan: newerThan, log: support.log) + let syncStreamContents = FeedlySyncStreamContentsOperation(account: account, resource: resource, service: service, isPagingEnabled: true, newerThan: newerThan, log: support.log) let completionExpectation = expectation(description: "Did Finish") syncStreamContents.completionBlock = { _ in @@ -79,7 +79,7 @@ class FeedlySyncStreamContentsOperationTests: XCTestCase { XCTAssertNil(serviceUnreadOnly) } - let syncStreamContents = FeedlySyncStreamContentsOperation(account: account, resource: resource, service: service, newerThan: newerThan, log: support.log) + let syncStreamContents = FeedlySyncStreamContentsOperation(account: account, resource: resource, service: service, isPagingEnabled: true, newerThan: newerThan, log: support.log) let completionExpectation = expectation(description: "Did Finish") syncStreamContents.completionBlock = { _ in @@ -120,7 +120,7 @@ class FeedlySyncStreamContentsOperationTests: XCTestCase { getStreamPageExpectation.fulfill() } - let syncStreamContents = FeedlySyncStreamContentsOperation(account: account, resource: resource, service: service, newerThan: newerThan, log: support.log) + let syncStreamContents = FeedlySyncStreamContentsOperation(account: account, resource: resource, service: service, isPagingEnabled: true, newerThan: newerThan, log: support.log) let completionExpectation = expectation(description: "Did Finish") syncStreamContents.completionBlock = { _ in diff --git a/Frameworks/Account/Feedly/Operations/FeedlyAddNewFeedOperation.swift b/Frameworks/Account/Feedly/Operations/FeedlyAddNewFeedOperation.swift index 261acb4fe..56fd11e0f 100644 --- a/Frameworks/Account/Feedly/Operations/FeedlyAddNewFeedOperation.swift +++ b/Frameworks/Account/Feedly/Operations/FeedlyAddNewFeedOperation.swift @@ -83,28 +83,28 @@ class FeedlyAddNewFeedOperation: FeedlyOperation, FeedlyOperationDelegate, Feedl let addRequest = FeedlyAddFeedToCollectionOperation(account: account, folder: folder, feedResource: feedResourceId, feedName: feedName, collectionId: collectionId, service: addToCollectionService) addRequest.delegate = self addRequest.downloadProgress = downloadProgress - self.operationQueue.addOperation(addRequest) + operationQueue.addOperation(addRequest) let createFeeds = FeedlyCreateFeedsForCollectionFoldersOperation(account: account, feedsAndFoldersProvider: addRequest, log: log) operationQueue.make(createFeeds, dependOn: addRequest) createFeeds.downloadProgress = downloadProgress - self.operationQueue.addOperation(createFeeds) + operationQueue.addOperation(createFeeds) let syncUnread = FeedlyIngestUnreadArticleIdsOperation(account: account, credentials: credentials, service: syncUnreadIdsService, database: database, newerThan: nil, log: log) operationQueue.make(syncUnread, dependOn: createFeeds) syncUnread.downloadProgress = downloadProgress - self.operationQueue.addOperation(syncUnread) + operationQueue.addOperation(syncUnread) - let syncFeed = FeedlySyncStreamContentsOperation(account: account, resource: feedResourceId, service: getStreamContentsService, newerThan: nil, log: log) + let syncFeed = FeedlySyncStreamContentsOperation(account: account, resource: feedResourceId, service: getStreamContentsService, isPagingEnabled: false, newerThan: nil, log: log) operationQueue.make(syncFeed, dependOn: syncUnread) syncFeed.downloadProgress = downloadProgress - self.operationQueue.addOperation(syncFeed) + operationQueue.addOperation(syncFeed) let finishOperation = FeedlyCheckpointOperation() finishOperation.checkpointDelegate = self finishOperation.downloadProgress = downloadProgress operationQueue.make(finishOperation, dependOn: syncFeed) - self.operationQueue.addOperation(finishOperation) + operationQueue.addOperation(finishOperation) } func feedlyOperation(_ operation: FeedlyOperation, didFailWith error: Error) { diff --git a/Frameworks/Account/Feedly/Operations/FeedlySyncStreamContentsOperation.swift b/Frameworks/Account/Feedly/Operations/FeedlySyncStreamContentsOperation.swift index dd5e45030..31ba1ac4f 100644 --- a/Frameworks/Account/Feedly/Operations/FeedlySyncStreamContentsOperation.swift +++ b/Frameworks/Account/Feedly/Operations/FeedlySyncStreamContentsOperation.swift @@ -17,13 +17,15 @@ final class FeedlySyncStreamContentsOperation: FeedlyOperation, FeedlyOperationD private let operationQueue = MainThreadOperationQueue() private let service: FeedlyGetStreamContentsService private let newerThan: Date? + private let isPagingEnabled: Bool private let log: OSLog private let finishOperation: FeedlyCheckpointOperation - init(account: Account, resource: FeedlyResourceId, service: FeedlyGetStreamContentsService, newerThan: Date?, log: OSLog) { + init(account: Account, resource: FeedlyResourceId, service: FeedlyGetStreamContentsService, isPagingEnabled: Bool, newerThan: Date?, log: OSLog) { self.account = account self.resource = resource self.service = service + self.isPagingEnabled = isPagingEnabled self.operationQueue.suspend() self.newerThan = newerThan self.log = log @@ -38,7 +40,7 @@ final class FeedlySyncStreamContentsOperation: FeedlyOperation, FeedlyOperationD convenience init(account: Account, credentials: Credentials, service: FeedlyGetStreamContentsService, newerThan: Date?, log: OSLog) { let all = FeedlyCategoryResourceId.Global.all(for: credentials.username) - self.init(account: account, resource: all, service: service, newerThan: newerThan, log: log) + self.init(account: account, resource: all, service: service, isPagingEnabled: true, newerThan: newerThan, log: log) } override func cancel() { @@ -98,7 +100,7 @@ final class FeedlySyncStreamContentsOperation: FeedlyOperation, FeedlyOperationD os_log(.debug, log: log, "Ingesting %i items from %@", stream.items.count, stream.id) - guard let continuation = stream.continuation else { + guard isPagingEnabled, let continuation = stream.continuation else { os_log(.debug, log: log, "Reached end of stream for %@", stream.id) return }