Added sync database integration

This commit is contained in:
Maurice Parker 2020-03-31 20:56:34 -05:00
parent c3b5d337c5
commit 0ce1bf5ebc

View File

@ -337,6 +337,17 @@ final class CloudKitAccountDelegate: AccountDelegate {
}
func markArticles(for account: Account, articles: Set<Article>, statusKey: ArticleStatus.Key, flag: Bool) -> Set<Article>? {
let syncStatuses = articles.map { article in
return SyncStatus(articleID: article.articleID, key: statusKey, flag: flag)
}
database.insertStatuses(syncStatuses)
database.selectPendingCount { result in
if let count = try? result.get(), count > 100 {
self.sendArticleStatus(for: account) { _ in }
}
}
return try? account.update(articles, statusKey: statusKey, flag: flag)
}
@ -377,10 +388,11 @@ final class CloudKitAccountDelegate: AccountDelegate {
}
func suspendDatabase() {
// Nothing to do
database.suspend()
}
func resume() {
refresher.resume()
database.resume()
}
}