From d8e2285f2bd75189e0c66a016ef74f8ddebc1b37 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Tue, 7 Jun 2022 14:04:58 -0700 Subject: [PATCH] Make sure titles are updated when fetching updated article content --- .../Sources/App/Views/WebReader/WebReader.swift | 6 ++---- .../App/Views/WebReader/WebReaderContainer.swift | 3 +-- .../App/Views/WebReader/WebReaderContent.swift | 15 ++++++--------- .../Models/DataModels/ArticleContent.swift | 3 +++ .../DataService/Queries/ArticleContentQuery.swift | 2 ++ 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift index c24689f14..514d9c8f4 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift @@ -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(), diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift index 6031bd02f..4050d4cff 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift @@ -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) diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContent.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContent.swift index 87902f01a..df4bece5a 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContent.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContent.swift @@ -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 {