diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift index f30aab097..78a8f3dce 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift @@ -70,6 +70,7 @@ struct WebReader: PlatformViewRepresentable { context.coordinator.linkHandler = openLinkAction context.coordinator.webViewActionHandler = webViewActionHandler context.coordinator.updateNavBarVisibilityRatio = navBarVisibilityRatioUpdater + context.coordinator.articleContentID = articleContent.id loadContent(webView: webView) return webView @@ -101,8 +102,10 @@ struct WebReader: PlatformViewRepresentable { } // If the webview had been terminated `needsReload` will have been set to true - if context.coordinator.needsReload { + // Or if the articleContent value has changed then it's id will be different from the coordinator's + if context.coordinator.needsReload || context.coordinator.articleContentID != articleContent.id { loadContent(webView: webView) + context.coordinator.articleContentID = articleContent.id context.coordinator.needsReload = false return } diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift index 11b7e0717..83c78fbf9 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift @@ -46,8 +46,20 @@ struct WebReaderContainerView: View { } func onHighlightListViewDismissal() { - print("has mutations: \(hasPerformedHighlightMutations)") - hasPerformedHighlightMutations = false + // Reload the web view if mutation happened in highlights list modal + guard hasPerformedHighlightMutations else { return } + + hasPerformedHighlightMutations.toggle() + + Task { + if let username = dataService.currentViewer?.username { + await viewModel.loadContent( + dataService: dataService, + username: username, + itemID: item.unwrappedID + ) + } + } } private func handleHighlightAction(message: WKScriptMessage) { diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderCoordinator.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderCoordinator.swift index acaaafd18..a08377a45 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderCoordinator.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderCoordinator.swift @@ -19,6 +19,7 @@ final class WebReaderCoordinator: NSObject { var previousShowNavBarActionID: UUID? var previousShareActionID: UUID? var updateNavBarVisibilityRatio: (Double) -> Void = { _ in } + var articleContentID = UUID() private var yOffsetAtStartOfDrag: Double? private var lastYOffset: Double = 0 private var hasDragged = false diff --git a/apple/OmnivoreKit/Sources/Models/DataModels/ArticleContent.swift b/apple/OmnivoreKit/Sources/Models/DataModels/ArticleContent.swift index 028dcbacc..86c5469d1 100644 --- a/apple/OmnivoreKit/Sources/Models/DataModels/ArticleContent.swift +++ b/apple/OmnivoreKit/Sources/Models/DataModels/ArticleContent.swift @@ -9,6 +9,7 @@ public enum ArticleContentStatus: String { } public struct ArticleContent { + public let id = UUID() public let title: String public let htmlContent: String public let highlightsJSONString: String