Ensure that no deleted articles are in the new and updated articles

This commit is contained in:
Maurice Parker 2020-04-26 05:46:43 -05:00
parent d0ace82d02
commit 4f54a21084
2 changed files with 7 additions and 0 deletions

View File

@ -627,6 +627,8 @@ private extension CloudKitAccountDelegate {
group.notify(queue: DispatchQueue.main) { group.notify(queue: DispatchQueue.main) {
newAndUpdatedArticles = newAndUpdatedArticles.subtracting(deletedArticles)
self.articlesZone.deleteArticles(deletedArticles) { _ in self.articlesZone.deleteArticles(deletedArticles) { _ in
self.refreshProgress.completeTask() self.refreshProgress.completeTask()
self.articlesZone.saveNewArticles(newAndUpdatedArticles) { _ in self.articlesZone.saveNewArticles(newAndUpdatedArticles) { _ in
@ -677,6 +679,8 @@ private extension CloudKitAccountDelegate {
newAndUpdatedArticles.formUnion(articleChanges.updatedArticles ?? Set<Article>()) newAndUpdatedArticles.formUnion(articleChanges.updatedArticles ?? Set<Article>())
let deletedArticles = articleChanges.deletedArticles ?? Set<Article>() let deletedArticles = articleChanges.deletedArticles ?? Set<Article>()
newAndUpdatedArticles = newAndUpdatedArticles.subtracting(deletedArticles)
self.articlesZone.deleteArticles(deletedArticles) { _ in self.articlesZone.deleteArticles(deletedArticles) { _ in
self.refreshProgress.completeTask() self.refreshProgress.completeTask()
self.articlesZone.saveNewArticles(newAndUpdatedArticles) { _ in self.articlesZone.saveNewArticles(newAndUpdatedArticles) { _ in
@ -756,6 +760,7 @@ private extension CloudKitAccountDelegate {
var newAndUpdatedArticles = articleChanges.newArticles ?? Set<Article>() var newAndUpdatedArticles = articleChanges.newArticles ?? Set<Article>()
newAndUpdatedArticles.formUnion(articleChanges.updatedArticles ?? Set<Article>()) newAndUpdatedArticles.formUnion(articleChanges.updatedArticles ?? Set<Article>())
let deletedArticles = articleChanges.deletedArticles ?? Set<Article>() let deletedArticles = articleChanges.deletedArticles ?? Set<Article>()
newAndUpdatedArticles = newAndUpdatedArticles.subtracting(deletedArticles)
self.articlesZone.deleteArticles(deletedArticles) { _ in self.articlesZone.deleteArticles(deletedArticles) { _ in
self.refreshProgress.completeTask() self.refreshProgress.completeTask()

View File

@ -217,6 +217,7 @@ private extension CloudKitAcountZoneDelegate {
var newAndUpdatedArticles = articleChanges.newArticles ?? Set<Article>() var newAndUpdatedArticles = articleChanges.newArticles ?? Set<Article>()
newAndUpdatedArticles.formUnion(articleChanges.updatedArticles ?? Set<Article>()) newAndUpdatedArticles.formUnion(articleChanges.updatedArticles ?? Set<Article>())
let deletedArticles = articleChanges.deletedArticles ?? Set<Article>() let deletedArticles = articleChanges.deletedArticles ?? Set<Article>()
newAndUpdatedArticles = newAndUpdatedArticles.subtracting(deletedArticles)
self.articlesZone?.deleteArticles(deletedArticles) { _ in self.articlesZone?.deleteArticles(deletedArticles) { _ in
self.refreshProgress?.completeTask() self.refreshProgress?.completeTask()
@ -259,6 +260,7 @@ private extension CloudKitAcountZoneDelegate {
var newAndUpdatedArticles = articleChanges.newArticles ?? Set<Article>() var newAndUpdatedArticles = articleChanges.newArticles ?? Set<Article>()
newAndUpdatedArticles.formUnion(articleChanges.updatedArticles ?? Set<Article>()) newAndUpdatedArticles.formUnion(articleChanges.updatedArticles ?? Set<Article>())
let deletedArticles = articleChanges.deletedArticles ?? Set<Article>() let deletedArticles = articleChanges.deletedArticles ?? Set<Article>()
newAndUpdatedArticles = newAndUpdatedArticles.subtracting(deletedArticles)
self.articlesZone?.deleteArticles(deletedArticles) { _ in self.articlesZone?.deleteArticles(deletedArticles) { _ in
self.refreshProgress?.completeTask() self.refreshProgress?.completeTask()