Sync highlights in search also
This commit is contained in:
@ -49,7 +49,8 @@ extension DataService {
|
||||
wordsCount: try $0.wordsCount(),
|
||||
downloadURL: try $0.url(),
|
||||
recommendations: try $0.recommendations(selection: recommendationSelection.list.nullable) ?? [],
|
||||
labels: try $0.labels(selection: feedItemLabelSelection.list.nullable) ?? []
|
||||
labels: try $0.labels(selection: feedItemLabelSelection.list.nullable) ?? [],
|
||||
highlights: try $0.highlights(selection: highlightSelection.list)
|
||||
),
|
||||
htmlContent: try $0.content(),
|
||||
highlights: try $0.highlights(selection: highlightSelection.list)
|
||||
|
||||
@ -291,7 +291,8 @@ private let libraryArticleSelection = Selection.Article {
|
||||
wordsCount: try $0.wordsCount(),
|
||||
downloadURL: try $0.url(),
|
||||
recommendations: try $0.recommendations(selection: recommendationSelection.list.nullable) ?? [],
|
||||
labels: try $0.labels(selection: feedItemLabelSelection.list.nullable) ?? []
|
||||
labels: try $0.labels(selection: feedItemLabelSelection.list.nullable) ?? [],
|
||||
highlights: try $0.highlights(selection: highlightSelection.list) ?? []
|
||||
)
|
||||
}
|
||||
|
||||
@ -334,7 +335,8 @@ private let searchItemSelection = Selection.SearchItem {
|
||||
wordsCount: try $0.wordsCount(),
|
||||
downloadURL: try $0.url(),
|
||||
recommendations: try $0.recommendations(selection: recommendationSelection.list.nullable) ?? [],
|
||||
labels: try $0.labels(selection: feedItemLabelSelection.list.nullable) ?? []
|
||||
labels: try $0.labels(selection: feedItemLabelSelection.list.nullable) ?? [],
|
||||
highlights: try $0.highlights(selection: highlightSelection.list.nullable) ?? []
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@ struct InternalLibraryItem {
|
||||
let downloadURL: String
|
||||
let recommendations: [InternalRecommendation]
|
||||
var labels: [InternalLinkedItemLabel]
|
||||
var highlights: [InternalHighlight]
|
||||
|
||||
var isPDF: Bool {
|
||||
if let contentReader = contentReader {
|
||||
@ -89,6 +90,15 @@ struct InternalLibraryItem {
|
||||
linkedItem.addToRecommendations(recommendation.asManagedObject(inContext: context))
|
||||
}
|
||||
|
||||
// Remove existing labels in case a label had been deleted
|
||||
if let existingHighlights = linkedItem.highlights {
|
||||
linkedItem.removeFromHighlights(existingHighlights)
|
||||
}
|
||||
|
||||
for highlight in highlights {
|
||||
linkedItem.addToHighlights(highlight.asManagedObject(context: context))
|
||||
}
|
||||
|
||||
return linkedItem
|
||||
}
|
||||
}
|
||||
@ -156,7 +166,8 @@ extension JSONArticle {
|
||||
wordsCount: wordsCount,
|
||||
downloadURL: downloadURL,
|
||||
recommendations: [],
|
||||
labels: []
|
||||
labels: [],
|
||||
highlights: []
|
||||
)
|
||||
|
||||
context.performAndWait {
|
||||
|
||||
Reference in New Issue
Block a user