Make sure deleted highlights are synced to iOS

This commit is contained in:
Jackson Harper 2022-11-16 15:33:22 +08:00 committed by Hongbo Wu
parent 5e4095f47e
commit 60a663e9bb

View file

@ -110,7 +110,15 @@ extension DataService {
let highlightObjects = articleProps.highlights.map {
$0.asManagedObject(context: self.backgroundContext)
}
linkedItem.addToHighlights(NSSet(array: highlightObjects))
let unsyncedHighlights = existingItem?.highlights?.filter { highlight in
if let highlight = highlight as? Highlight, highlight.serverSyncStatus == ServerSyncStatus.isNSync.rawValue {
return false
}
return true
}.compactMap { $0 as? Highlight } ?? []
linkedItem.highlights = NSSet(array: highlightObjects + unsyncedHighlights)
linkedItem.htmlContent = articleProps.htmlContent
linkedItem.id = articleProps.item.id
linkedItem.state = articleProps.item.state.rawValue