Reload article image on image load notifications.

This commit is contained in:
Maurice Parker 2019-11-18 19:44:31 -06:00
parent 198dec68b1
commit 188c1f8d8e
1 changed files with 22 additions and 1 deletions

View File

@ -100,14 +100,31 @@ final class DetailWebViewController: NSViewController, WKUIDelegate {
#if !MAC_APP_STORE #if !MAC_APP_STORE
webInspectorEnabled = AppDefaults.webInspectorEnabled webInspectorEnabled = AppDefaults.webInspectorEnabled
NotificationCenter.default.addObserver(self, selector: #selector(webInspectorEnabledDidChange(_:)), name: .WebInspectorEnabledDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(webInspectorEnabledDidChange(_:)), name: .WebInspectorEnabledDidChange, object: nil)
#endif #endif
NotificationCenter.default.addObserver(self, selector: #selector(webFeedIconDidBecomeAvailable(_:)), name: .WebFeedIconDidBecomeAvailable, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(avatarDidBecomeAvailable(_:)), name: .AvatarDidBecomeAvailable, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(faviconDidBecomeAvailable(_:)), name: .FaviconDidBecomeAvailable, object: nil)
webView.loadHTMLString(ArticleRenderer.page.html, baseURL: ArticleRenderer.page.baseURL) webView.loadHTMLString(ArticleRenderer.page.html, baseURL: ArticleRenderer.page.baseURL)
} }
// MARK: Notifications
@objc func webFeedIconDidBecomeAvailable(_ note: Notification) {
reloadArticleImage()
}
@objc func avatarDidBecomeAvailable(_ note: Notification) {
reloadArticleImage()
}
@objc func faviconDidBecomeAvailable(_ note: Notification) {
reloadArticleImage()
}
// MARK: Scrolling // MARK: Scrolling
func canScrollDown(_ callback: @escaping (Bool) -> Void) { func canScrollDown(_ callback: @escaping (Bool) -> Void) {
@ -175,6 +192,10 @@ struct TemplateData: Codable {
private extension DetailWebViewController { private extension DetailWebViewController {
func reloadArticleImage() {
webView.evaluateJavaScript("reloadArticleImage()")
}
func reloadHTML() { func reloadHTML() {
let style = ArticleStylesManager.shared.currentStyle let style = ArticleStylesManager.shared.currentStyle
let rendering: ArticleRenderer.Rendering let rendering: ArticleRenderer.Rendering