mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Filter out highlights that are scheduled for deletion
This commit is contained in:
parent
fd853e65ee
commit
be4fea153a
2 changed files with 13 additions and 2 deletions
|
|
@ -14,7 +14,14 @@ struct HighlightListItemParams: Identifiable {
|
|||
let createdBy: InternalUserProfile?
|
||||
}
|
||||
|
||||
struct NoteItemParams: Identifiable {
|
||||
let id = UUID()
|
||||
let highlightID: String
|
||||
let annotation: String
|
||||
}
|
||||
|
||||
@MainActor final class NotebookViewModel: ObservableObject {
|
||||
@Published var noteItem: NoteItemParams?
|
||||
@Published var highlightItems = [HighlightListItemParams]()
|
||||
|
||||
func load(itemObjectID: NSManagedObjectID, dataService: DataService) {
|
||||
|
|
@ -72,7 +79,9 @@ struct HighlightListItemParams: Identifiable {
|
|||
}
|
||||
|
||||
private func loadHighlights(item: LinkedItem) {
|
||||
let unsortedHighlights = item.highlights.asArray(of: Highlight.self).filter { $0.type == "HIGHLIGHT" }
|
||||
let notes = item.highlights.asArray(of: Highlight.self).filter { $0.type == "NOTE" }
|
||||
let unsortedHighlights = item.highlights.asArray(of: Highlight.self)
|
||||
.filter { $0.type == "HIGHLIGHT" && $0.serverSyncStatus != ServerSyncStatus.needsDeletion.rawValue }
|
||||
|
||||
let highlights = unsortedHighlights.sorted { left, right in
|
||||
if left.positionPercent > 0, right.positionPercent > 0 {
|
||||
|
|
|
|||
|
|
@ -87,7 +87,9 @@ extension DataService {
|
|||
return ArticleContent(
|
||||
title: linkedItem.unwrappedTitle,
|
||||
htmlContent: htmlContent,
|
||||
highlightsJSONString: highlights.map { InternalHighlight.make(from: $0) }.asJSONString,
|
||||
highlightsJSONString: highlights
|
||||
.filter { $0.serverSyncStatus != ServerSyncStatus.needsDeletion.rawValue }
|
||||
.map { InternalHighlight.make(from: $0) }.asJSONString,
|
||||
contentStatus: .succeeded,
|
||||
objectID: linkedItem.objectID
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue