Make article rendering stop flashing!
This commit is contained in:
parent
9836fb781c
commit
5f573fc985
|
@ -12,10 +12,9 @@ import Articles
|
|||
struct ArticleContainerView: View {
|
||||
|
||||
@EnvironmentObject private var sceneModel: SceneModel
|
||||
var articles: [Article]
|
||||
|
||||
@ViewBuilder var body: some View {
|
||||
ArticleView(sceneModel: sceneModel, articles: articles)
|
||||
ArticleView(sceneModel: sceneModel)
|
||||
.modifier(ArticleToolbarModifier())
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ struct TimelineView: View {
|
|||
.help(timelineModel.isReadFiltered ?? false ? "Show Read Articles" : "Filter Read Articles")
|
||||
}
|
||||
ZStack {
|
||||
NavigationLink(destination: ArticleContainerView(articles: timelineModel.selectedArticles), isActive: $navigate) {
|
||||
NavigationLink(destination: ArticleContainerView(), isActive: $navigate) {
|
||||
EmptyView()
|
||||
}.hidden()
|
||||
List(timelineModel.timelineItems, selection: $timelineModel.selectedArticleIDs) { timelineItem in
|
||||
|
|
|
@ -12,17 +12,14 @@ import Articles
|
|||
struct ArticleView: NSViewControllerRepresentable {
|
||||
|
||||
var sceneModel: SceneModel
|
||||
var articles: [Article]
|
||||
|
||||
func makeNSViewController(context: Context) -> WebViewController {
|
||||
let controller = WebViewController()
|
||||
controller.sceneModel = sceneModel
|
||||
controller.articles = articles
|
||||
return controller
|
||||
}
|
||||
|
||||
func updateNSViewController(_ uiViewController: WebViewController, context: Context) {
|
||||
|
||||
func updateNSViewController(_ controller: WebViewController, context: Context) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
//
|
||||
|
||||
import AppKit
|
||||
import Combine
|
||||
import RSCore
|
||||
import Articles
|
||||
|
||||
|
@ -46,7 +47,15 @@ class WebViewController: NSViewController {
|
|||
var sceneModel: SceneModel?
|
||||
weak var delegate: WebViewControllerDelegate?
|
||||
|
||||
var articles: [Article]?
|
||||
var articles: [Article]? {
|
||||
didSet {
|
||||
if oldValue != articles {
|
||||
loadWebView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var selectedArticlesCancellable: AnyCancellable?
|
||||
|
||||
override func loadView() {
|
||||
view = NSView()
|
||||
|
@ -71,7 +80,9 @@ class WebViewController: NSViewController {
|
|||
statusBarView.heightAnchor.constraint(equalToConstant: 20)
|
||||
])
|
||||
|
||||
loadWebView()
|
||||
selectedArticlesCancellable = sceneModel?.timelineModel.$selectedArticles.sink { [weak self] articles in
|
||||
self?.articles = articles
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Notifications
|
||||
|
@ -235,6 +246,8 @@ private extension WebViewController {
|
|||
sceneModel?.webViewProvider?.dequeueWebView() { webView in
|
||||
|
||||
// Add the webview
|
||||
self.webView = webView
|
||||
|
||||
webView.translatesAutoresizingMaskIntoConstraints = false
|
||||
self.view.addSubview(webView, positioned: .below, relativeTo: self.statusBarView)
|
||||
NSLayoutConstraint.activate([
|
||||
|
|
Loading…
Reference in New Issue