Display labels on the appreader page

This commit is contained in:
Jackson Harper
2022-05-03 21:00:04 -07:00
parent fb96265a00
commit 2c56073406
4 changed files with 16 additions and 1 deletions

View File

@ -66,6 +66,7 @@ struct WebReaderContent {
contentReader: "WEB",
readingProgressPercent: \(item.readingProgress),
readingProgressAnchorIndex: \(item.readingProgressAnchor),
labels: \(item.labelsJSONString),
highlights: \(highlightsJSONString),
}

View File

@ -58,6 +58,19 @@ public extension LinkedItem {
return URL(string: pageURLString ?? "")
}
var labelsJSONString: String {
let labels = self.labels.asArray(of: LinkedItemLabel.self).map { label in
[
"id": NSString(string: label.id ?? ""),
"color": NSString(string: label.color ?? ""),
"name": NSString(string: label.name ?? ""),
"description": NSString(string: label.labelDescription ?? "")
]
}
guard let JSON = (try? JSONSerialization.data(withJSONObject: labels, options: .prettyPrinted)) else { return "[]" }
return String(data: JSON, encoding: .utf8) ?? "[]"
}
static func lookup(byID itemID: String, inContext context: NSManagedObjectContext) -> LinkedItem? {
let fetchRequest: NSFetchRequest<Models.LinkedItem> = LinkedItem.fetchRequest()
fetchRequest.predicate = NSPredicate(

File diff suppressed because one or more lines are too long

View File

@ -34,6 +34,7 @@ const App = () => {
>
<ArticleContainer
article={window.omnivoreArticle}
labels={window.omnivoreArticle.labels}
scrollElementRef={React.createRef()}
isAppleAppEmbed={true}
highlightBarDisabled={true}