Skip to content

Commit

Permalink
Aggregation: delete articles that are no longer in the original site
Browse files Browse the repository at this point in the history
  • Loading branch information
livid committed Mar 20, 2024
1 parent fe212be commit 4f3fd0f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Planet/Entities/MyPlanetModel+Aggregate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,25 @@ extension MyPlanetModel {
}
}
}
// Delete articles that are no longer in the original site
var deleted = 0
for article in self.articles {
if article.originalSiteDomain == site,
!planet.articles.contains(where: { $0.id.uuidString == article.originalPostID })
{
debugPrint("Aggregation: deleting \(article.originalPostID) from \(site)")
article.delete()
deleted += 1
}
}
if deleted > 0 {
self.tags = self.consolidateTags()
try? save()
try? await savePublic()
Task { @MainActor in
PlanetStore.shared.refreshSelectedArticles()
}
}
}
catch {
debugPrint("Aggregation: failed to fetch \(site): \(error)")
Expand Down

0 comments on commit 4f3fd0f

Please sign in to comment.