Create fetchAndProcessAllArticleIDs function to replace FeedlyIngestStreamArticleIDsOperation.
This commit is contained in:
parent
90fd697f0d
commit
c6c457e718
@ -902,11 +902,44 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
|||||||
func fetchAndProcessStarredArticleIDs() async throws {
|
func fetchAndProcessStarredArticleIDs() async throws {
|
||||||
|
|
||||||
// To replace FeedlyIngestStarredArticleIDsOperation
|
// To replace FeedlyIngestStarredArticleIDsOperation
|
||||||
|
|
||||||
let remoteArticleIDs = try await fetchRemoteStarredArticleIDs()
|
let remoteArticleIDs = try await fetchRemoteStarredArticleIDs()
|
||||||
try await processStarredArticleIDs(remoteArticleIDs: remoteArticleIDs)
|
try await processStarredArticleIDs(remoteArticleIDs: remoteArticleIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func fetchAllArticleIDs() async throws -> Set<String> {
|
||||||
|
|
||||||
|
guard let userID else { return Set<String>() }
|
||||||
|
|
||||||
|
var allArticleIDs = Set<String>()
|
||||||
|
let resource = FeedlyCategoryResourceID.Global.all(for: userID)
|
||||||
|
|
||||||
|
func fetchStreamIDs(_ continuation: String?) async throws {
|
||||||
|
|
||||||
|
let streamIDs = try await caller.getStreamIDs(for: resource, continuation: continuation, newerThan: nil, unreadOnly: nil)
|
||||||
|
|
||||||
|
allArticleIDs.formUnion(streamIDs.ids)
|
||||||
|
|
||||||
|
guard let continuation = streamIDs.continuation else {
|
||||||
|
os_log(.debug, log: self.log, "Reached end of stream for %@", resource.id)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try await fetchStreamIDs(continuation)
|
||||||
|
}
|
||||||
|
|
||||||
|
return allArticleIDs
|
||||||
|
}
|
||||||
|
|
||||||
|
func fetchAndProcessAllArticleIDs() async throws {
|
||||||
|
|
||||||
|
// To replace FeedlyIngestStreamArticleIDsOperation
|
||||||
|
|
||||||
|
guard let account else { return }
|
||||||
|
|
||||||
|
let allArticleIDs = try await fetchAllArticleIDs()
|
||||||
|
try await account.createStatusesIfNeeded(articleIDs: allArticleIDs)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Suspend and Resume (for iOS)
|
// MARK: Suspend and Resume (for iOS)
|
||||||
|
|
||||||
@ -918,7 +951,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Suspend the SQLLite databases
|
/// Suspend the SQLite databases
|
||||||
func suspendDatabase() {
|
func suspendDatabase() {
|
||||||
Task {
|
Task {
|
||||||
await syncDatabase.suspend()
|
await syncDatabase.suspend()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user