Display labels on the appreader page
This commit is contained in:
@ -66,6 +66,7 @@ struct WebReaderContent {
|
|||||||
contentReader: "WEB",
|
contentReader: "WEB",
|
||||||
readingProgressPercent: \(item.readingProgress),
|
readingProgressPercent: \(item.readingProgress),
|
||||||
readingProgressAnchorIndex: \(item.readingProgressAnchor),
|
readingProgressAnchorIndex: \(item.readingProgressAnchor),
|
||||||
|
labels: \(item.labelsJSONString),
|
||||||
highlights: \(highlightsJSONString),
|
highlights: \(highlightsJSONString),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,6 +58,19 @@ public extension LinkedItem {
|
|||||||
return URL(string: pageURLString ?? "")
|
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? {
|
static func lookup(byID itemID: String, inContext context: NSManagedObjectContext) -> LinkedItem? {
|
||||||
let fetchRequest: NSFetchRequest<Models.LinkedItem> = LinkedItem.fetchRequest()
|
let fetchRequest: NSFetchRequest<Models.LinkedItem> = LinkedItem.fetchRequest()
|
||||||
fetchRequest.predicate = NSPredicate(
|
fetchRequest.predicate = NSPredicate(
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -34,6 +34,7 @@ const App = () => {
|
|||||||
>
|
>
|
||||||
<ArticleContainer
|
<ArticleContainer
|
||||||
article={window.omnivoreArticle}
|
article={window.omnivoreArticle}
|
||||||
|
labels={window.omnivoreArticle.labels}
|
||||||
scrollElementRef={React.createRef()}
|
scrollElementRef={React.createRef()}
|
||||||
isAppleAppEmbed={true}
|
isAppleAppEmbed={true}
|
||||||
highlightBarDisabled={true}
|
highlightBarDisabled={true}
|
||||||
|
|||||||
Reference in New Issue
Block a user