2019-09-19 04:56:43 +02:00
|
|
|
//
|
|
|
|
// FeedlyUpdateAccountFeedsWithItemsOperation.swift
|
|
|
|
// Account
|
|
|
|
//
|
|
|
|
// Created by Kiel Gillard on 20/9/19.
|
|
|
|
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import RSParser
|
|
|
|
import os.log
|
|
|
|
|
2020-01-19 23:19:06 +01:00
|
|
|
/// Combine the articles with their feeds for a specific account.
|
2019-09-23 09:29:53 +02:00
|
|
|
final class FeedlyUpdateAccountFeedsWithItemsOperation: FeedlyOperation {
|
2020-01-19 23:19:06 +01:00
|
|
|
|
2019-09-19 04:56:43 +02:00
|
|
|
private let account: Account
|
|
|
|
private let organisedItemsProvider: FeedlyParsedItemsByFeedProviding
|
|
|
|
private let log: OSLog
|
2020-01-19 23:19:06 +01:00
|
|
|
|
2019-09-19 04:56:43 +02:00
|
|
|
init(account: Account, organisedItemsProvider: FeedlyParsedItemsByFeedProviding, log: OSLog) {
|
|
|
|
self.account = account
|
|
|
|
self.organisedItemsProvider = organisedItemsProvider
|
|
|
|
self.log = log
|
|
|
|
}
|
|
|
|
|
2020-01-16 06:30:37 +01:00
|
|
|
override func run() {
|
2019-11-15 03:11:41 +01:00
|
|
|
let webFeedIDsAndItems = organisedItemsProvider.parsedItemsKeyedByFeedId
|
2019-09-19 04:56:43 +02:00
|
|
|
|
2019-12-17 23:19:00 +01:00
|
|
|
account.update(webFeedIDsAndItems: webFeedIDsAndItems, defaultRead: true) { databaseError in
|
|
|
|
if let error = databaseError {
|
2020-01-19 23:19:06 +01:00
|
|
|
self.didFinish(with: error)
|
2019-12-17 23:19:00 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-01-09 06:24:47 +01:00
|
|
|
os_log(.debug, log: self.log, "Updated %i feeds for \"%@\"", webFeedIDsAndItems.count, self.organisedItemsProvider.parsedItemsByFeedProviderName)
|
2019-09-19 04:56:43 +02:00
|
|
|
self.didFinish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|