Reload Article images when their availablity notification arrives. Issue #1317
This commit is contained in:
parent
fc235a029e
commit
198dec68b1
|
@ -141,7 +141,7 @@ private extension ArticleRenderer {
|
||||||
d["title"] = title
|
d["title"] = title
|
||||||
|
|
||||||
d["body"] = body
|
d["body"] = body
|
||||||
d["avatars"] = "<td class=\"header rightAlign avatar\"><img src=\"\(ArticleRenderer.imageIconScheme)://\" height=48 width=48 /></td>";
|
d["avatars"] = "<td class=\"header rightAlign avatar\"><img id=\"nnwImageIcon\" src=\"\(ArticleRenderer.imageIconScheme)://\" height=48 width=48 /></td>";
|
||||||
|
|
||||||
var feedLink = ""
|
var feedLink = ""
|
||||||
if let feedTitle = article.webFeed?.nameForDisplay {
|
if let feedTitle = article.webFeed?.nameForDisplay {
|
||||||
|
|
|
@ -21,6 +21,11 @@ function convertImgSrc() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reloadArticleImage() {
|
||||||
|
var image = document.getElementById("nnwImageIcon");
|
||||||
|
image.src = "nnwImageIcon://";
|
||||||
|
}
|
||||||
|
|
||||||
function error() {
|
function error() {
|
||||||
document.body.innerHTML = "error";
|
document.body.innerHTML = "error";
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,9 @@ class ArticleViewController: UIViewController {
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(statusesDidChange(_:)), name: .StatusesDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(statusesDidChange(_:)), name: .StatusesDidChange, object: nil)
|
||||||
|
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)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange(_:)), name: UIContentSizeCategory.didChangeNotification, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange(_:)), name: UIContentSizeCategory.didChangeNotification, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
|
||||||
|
|
||||||
|
@ -211,6 +214,18 @@ class ArticleViewController: UIViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func webFeedIconDidBecomeAvailable(_ note: Notification) {
|
||||||
|
reloadArticleImage()
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func avatarDidBecomeAvailable(_ note: Notification) {
|
||||||
|
reloadArticleImage()
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func faviconDidBecomeAvailable(_ note: Notification) {
|
||||||
|
reloadArticleImage()
|
||||||
|
}
|
||||||
|
|
||||||
@objc func contentSizeCategoryDidChange(_ note: Notification) {
|
@objc func contentSizeCategoryDidChange(_ note: Notification) {
|
||||||
reloadHTML()
|
reloadHTML()
|
||||||
}
|
}
|
||||||
|
@ -427,6 +442,10 @@ private struct ImageClickMessage: Codable {
|
||||||
|
|
||||||
private extension ArticleViewController {
|
private extension ArticleViewController {
|
||||||
|
|
||||||
|
func reloadArticleImage() {
|
||||||
|
webView?.evaluateJavaScript("reloadArticleImage()")
|
||||||
|
}
|
||||||
|
|
||||||
func imageWasClicked(body: String?) {
|
func imageWasClicked(body: String?) {
|
||||||
guard let body = body,
|
guard let body = body,
|
||||||
let data = body.data(using: .utf8),
|
let data = body.data(using: .utf8),
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
//
|
|
||||||
// ThemedNavigationController.swift
|
|
||||||
// NetNewsWire
|
|
||||||
//
|
|
||||||
// Created by Maurice Parker on 8/22/19.
|
|
||||||
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
class ThemedNavigationController: UINavigationController {
|
|
||||||
|
|
||||||
static func template() -> UINavigationController {
|
|
||||||
let navController = ThemedNavigationController()
|
|
||||||
navController.configure()
|
|
||||||
return navController
|
|
||||||
}
|
|
||||||
|
|
||||||
static func template(rootViewController: UIViewController) -> UINavigationController {
|
|
||||||
let navController = ThemedNavigationController(rootViewController: rootViewController)
|
|
||||||
navController.configure()
|
|
||||||
return navController
|
|
||||||
}
|
|
||||||
|
|
||||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
|
||||||
super.traitCollectionDidChange(previousTraitCollection)
|
|
||||||
if traitCollection.userInterfaceStyle != previousTraitCollection?.userInterfaceStyle {
|
|
||||||
configure()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func configure() {
|
|
||||||
isToolbarHidden = false
|
|
||||||
view.backgroundColor = AppAssets.barBackgroundColor
|
|
||||||
|
|
||||||
let navigationAppearance = UINavigationBarAppearance()
|
|
||||||
navigationAppearance.backgroundColor = AppAssets.barBackgroundColor
|
|
||||||
navigationAppearance.titleTextAttributes = [.foregroundColor: UIColor.label]
|
|
||||||
navigationAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.label]
|
|
||||||
navigationBar.standardAppearance = navigationAppearance
|
|
||||||
navigationBar.tintColor = AppAssets.primaryAccentColor
|
|
||||||
|
|
||||||
let toolbarAppearance = UIToolbarAppearance()
|
|
||||||
toolbarAppearance.backgroundColor = AppAssets.barBackgroundColor
|
|
||||||
toolbar.standardAppearance = toolbarAppearance
|
|
||||||
toolbar.compactAppearance = toolbarAppearance
|
|
||||||
toolbar.tintColor = AppAssets.primaryAccentColor
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue