Separate refreshers so that we don't send out duplicate unread statuses for new records.
This commit is contained in:
parent
6ec11119f8
commit
d6a4005336
|
@ -37,7 +37,7 @@ final class CloudKitAccountDelegate: AccountDelegate {
|
|||
|
||||
weak var account: Account?
|
||||
|
||||
private lazy var refresher: LocalAccountRefresher? = {
|
||||
private lazy var refresher: LocalAccountRefresher = {
|
||||
let refresher = LocalAccountRefresher()
|
||||
refresher.delegate = self
|
||||
return refresher
|
||||
|
@ -482,7 +482,6 @@ final class CloudKitAccountDelegate: AccountDelegate {
|
|||
articlesZone.delegate = CloudKitArticlesZoneDelegate(account: account,
|
||||
database: database,
|
||||
articlesZone: articlesZone,
|
||||
refresher: refresher,
|
||||
refreshProgress: refreshProgress)
|
||||
|
||||
// Check to see if this is a new account and initialize anything we need
|
||||
|
@ -516,7 +515,7 @@ final class CloudKitAccountDelegate: AccountDelegate {
|
|||
// MARK: Suspend and Resume (for iOS)
|
||||
|
||||
func suspendNetwork() {
|
||||
refresher?.suspend()
|
||||
refresher.suspend()
|
||||
}
|
||||
|
||||
func suspendDatabase() {
|
||||
|
@ -524,7 +523,7 @@ final class CloudKitAccountDelegate: AccountDelegate {
|
|||
}
|
||||
|
||||
func resume() {
|
||||
refresher?.resume()
|
||||
refresher.resume()
|
||||
database.resume()
|
||||
}
|
||||
}
|
||||
|
@ -570,7 +569,7 @@ private extension CloudKitAccountDelegate {
|
|||
return
|
||||
}
|
||||
|
||||
self.refresher?.refreshFeeds(webFeeds) {
|
||||
self.refresher.refreshFeeds(webFeeds) {
|
||||
|
||||
account.metadata.lastArticleFetchEndTime = Date()
|
||||
|
||||
|
@ -629,7 +628,7 @@ extension CloudKitAccountDelegate: LocalAccountRefresherDelegate {
|
|||
}
|
||||
|
||||
func localAccountRefresherDidFinish(_ refresher: LocalAccountRefresher) {
|
||||
self.refreshProgress.clear()
|
||||
refreshProgress.clear()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ import RSParser
|
|||
import RSWeb
|
||||
import CloudKit
|
||||
import SyncDatabase
|
||||
import Articles
|
||||
import ArticlesDatabase
|
||||
|
||||
class CloudKitArticlesZoneDelegate: CloudKitZoneDelegate {
|
||||
|
||||
|
@ -20,14 +22,18 @@ class CloudKitArticlesZoneDelegate: CloudKitZoneDelegate {
|
|||
weak var account: Account?
|
||||
var database: SyncDatabase
|
||||
weak var articlesZone: CloudKitArticlesZone?
|
||||
weak var refresher: LocalAccountRefresher?
|
||||
weak var refreshProgress: DownloadProgress?
|
||||
|
||||
private lazy var refresher: LocalAccountRefresher = {
|
||||
let refresher = LocalAccountRefresher()
|
||||
refresher.delegate = self
|
||||
return refresher
|
||||
}()
|
||||
|
||||
init(account: Account, database: SyncDatabase, articlesZone: CloudKitArticlesZone, refresher: LocalAccountRefresher?, refreshProgress: DownloadProgress?) {
|
||||
init(account: Account, database: SyncDatabase, articlesZone: CloudKitArticlesZone, refreshProgress: DownloadProgress?) {
|
||||
self.account = account
|
||||
self.database = database
|
||||
self.articlesZone = articlesZone
|
||||
self.refresher = refresher
|
||||
self.refreshProgress = refreshProgress
|
||||
}
|
||||
|
||||
|
@ -112,7 +118,7 @@ private extension CloudKitArticlesZoneDelegate {
|
|||
|
||||
webFeeds.forEach { $0.dropConditionalGetInfo() }
|
||||
self.refreshProgress?.addToNumberOfTasksAndRemaining(webFeeds.count)
|
||||
self.refresher?.refreshFeeds(webFeeds) {
|
||||
self.refresher.refreshFeeds(webFeeds) {
|
||||
group.leave()
|
||||
}
|
||||
|
||||
|
@ -196,3 +202,17 @@ private extension CloudKitArticlesZoneDelegate {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
extension CloudKitArticlesZoneDelegate: LocalAccountRefresherDelegate {
|
||||
|
||||
func localAccountRefresher(_ refresher: LocalAccountRefresher, didProcess newAndUpdatedArticles: NewAndUpdatedArticles) {
|
||||
}
|
||||
|
||||
func localAccountRefresher(_ refresher: LocalAccountRefresher, requestCompletedFor: WebFeed) {
|
||||
refreshProgress?.completeTask()
|
||||
}
|
||||
|
||||
func localAccountRefresherDidFinish(_ refresher: LocalAccountRefresher) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue