Added sync database integration
This commit is contained in:
parent
c3b5d337c5
commit
0ce1bf5ebc
@ -337,6 +337,17 @@ final class CloudKitAccountDelegate: AccountDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func markArticles(for account: Account, articles: Set<Article>, statusKey: ArticleStatus.Key, flag: Bool) -> Set<Article>? {
|
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)
|
return try? account.update(articles, statusKey: statusKey, flag: flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,10 +388,11 @@ final class CloudKitAccountDelegate: AccountDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func suspendDatabase() {
|
func suspendDatabase() {
|
||||||
// Nothing to do
|
database.suspend()
|
||||||
}
|
}
|
||||||
|
|
||||||
func resume() {
|
func resume() {
|
||||||
refresher.resume()
|
refresher.resume()
|
||||||
|
database.resume()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user