mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Make sure titles are updated when fetching updated article content
This commit is contained in:
parent
611b237e17
commit
d8e2285f2b
5 changed files with 14 additions and 15 deletions
|
|
@ -6,9 +6,8 @@ import WebKit
|
|||
|
||||
#if os(iOS)
|
||||
struct WebReader: UIViewRepresentable {
|
||||
let htmlContent: String
|
||||
let highlightsJSONString: String
|
||||
let item: LinkedItem
|
||||
let articleContent: ArticleContent
|
||||
let openLinkAction: (URL) -> Void
|
||||
let webViewActionHandler: (WKScriptMessage, WKScriptMessageReplyHandler?) -> Void
|
||||
let navBarVisibilityRatioUpdater: (Double) -> Void
|
||||
|
|
@ -143,9 +142,8 @@ import WebKit
|
|||
|
||||
webView.loadHTMLString(
|
||||
WebReaderContent(
|
||||
htmlContent: htmlContent,
|
||||
highlightsJSONString: highlightsJSONString,
|
||||
item: item,
|
||||
articleContent: articleContent,
|
||||
isDark: UITraitCollection.current.userInterfaceStyle == .dark,
|
||||
fontSize: fontSize(),
|
||||
lineHeight: lineHeight(),
|
||||
|
|
|
|||
|
|
@ -136,9 +136,8 @@ import WebKit
|
|||
ZStack {
|
||||
if let articleContent = viewModel.articleContent {
|
||||
WebReader(
|
||||
htmlContent: articleContent.htmlContent,
|
||||
highlightsJSONString: articleContent.highlightsJSONString,
|
||||
item: item,
|
||||
articleContent: articleContent,
|
||||
openLinkAction: {
|
||||
#if os(macOS)
|
||||
NSWorkspace.shared.open($0)
|
||||
|
|
|
|||
|
|
@ -7,16 +7,14 @@ struct WebReaderContent {
|
|||
let textFontSize: Int
|
||||
let lineHeight: Int
|
||||
let margin: Int
|
||||
let htmlContent: String
|
||||
let highlightsJSONString: String
|
||||
let item: LinkedItem
|
||||
let themeKey: String
|
||||
let fontFamily: WebFont
|
||||
let articleContent: ArticleContent
|
||||
|
||||
init(
|
||||
htmlContent: String,
|
||||
highlightsJSONString: String,
|
||||
item: LinkedItem,
|
||||
articleContent: ArticleContent,
|
||||
isDark: Bool,
|
||||
fontSize: Int,
|
||||
lineHeight: Int,
|
||||
|
|
@ -26,11 +24,10 @@ struct WebReaderContent {
|
|||
self.textFontSize = fontSize
|
||||
self.lineHeight = lineHeight
|
||||
self.margin = margin
|
||||
self.htmlContent = htmlContent
|
||||
self.highlightsJSONString = highlightsJSONString
|
||||
self.item = item
|
||||
self.themeKey = isDark ? "Gray" : "LightGray"
|
||||
self.fontFamily = fontFamily
|
||||
self.articleContent = articleContent
|
||||
}
|
||||
|
||||
// swiftlint:disable line_length
|
||||
|
|
@ -52,7 +49,7 @@ struct WebReaderContent {
|
|||
<body>
|
||||
<div id="root" />
|
||||
<div id='_omnivore-htmlContent' style="display: none;">
|
||||
\(htmlContent)
|
||||
\(articleContent.htmlContent)
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
window.omnivoreEnv = {
|
||||
|
|
@ -70,14 +67,14 @@ struct WebReaderContent {
|
|||
savedAt: \(savedAt),
|
||||
publishedAt: \(publishedAt),
|
||||
url: `\(item.unwrappedPageURLString)`,
|
||||
title: `\(item.unwrappedTitle.replacingOccurrences(of: "`", with: "\\`"))`,
|
||||
title: `\(articleContent.title.replacingOccurrences(of: "`", with: "\\`"))`,
|
||||
content: document.getElementById('_omnivore-htmlContent').innerHTML,
|
||||
originalArticleUrl: "\(item.unwrappedPageURLString)",
|
||||
contentReader: "WEB",
|
||||
readingProgressPercent: \(item.readingProgress),
|
||||
readingProgressAnchorIndex: \(item.readingProgressAnchor),
|
||||
labels: \(item.labelsJSONString),
|
||||
highlights: \(highlightsJSONString),
|
||||
highlights: \(articleContent.highlightsJSONString),
|
||||
}
|
||||
|
||||
window.fontSize = \(textFontSize)
|
||||
|
|
|
|||
|
|
@ -8,15 +8,18 @@ public enum ArticleContentStatus {
|
|||
}
|
||||
|
||||
public struct ArticleContent {
|
||||
public let title: String
|
||||
public let htmlContent: String
|
||||
public let highlightsJSONString: String
|
||||
public let contentStatus: ArticleContentStatus
|
||||
|
||||
public init(
|
||||
title: String,
|
||||
htmlContent: String,
|
||||
highlightsJSONString: String,
|
||||
contentStatus: ArticleContentStatus
|
||||
) {
|
||||
self.title = title
|
||||
self.htmlContent = htmlContent
|
||||
self.highlightsJSONString = highlightsJSONString
|
||||
self.contentStatus = contentStatus
|
||||
|
|
|
|||
|
|
@ -177,6 +177,7 @@ extension DataService {
|
|||
}
|
||||
|
||||
let articleContent = ArticleContent(
|
||||
title: result.item.title,
|
||||
htmlContent: result.htmlContent,
|
||||
highlightsJSONString: result.highlights.asJSONString,
|
||||
contentStatus: result.item.isPDF ? .succeeded : .make(from: result.contentStatus)
|
||||
|
|
@ -302,6 +303,7 @@ extension DataService {
|
|||
.filter { $0.serverSyncStatus != ServerSyncStatus.needsDeletion.rawValue }
|
||||
|
||||
return ArticleContent(
|
||||
title: linkedItem.unwrappedTitle,
|
||||
htmlContent: htmlContent,
|
||||
highlightsJSONString: highlights.map { InternalHighlight.make(from: $0) }.asJSONString,
|
||||
contentStatus: .succeeded
|
||||
|
|
|
|||
Loading…
Reference in a new issue