Change to use the correct URL when reloading an image.

This commit is contained in:
Maurice Parker 2020-01-27 16:27:13 -07:00
parent 3a99e6430f
commit dd5633b5ae
3 changed files with 17 additions and 4 deletions

View File

@ -27,6 +27,17 @@ final class DetailWebViewController: NSViewController, WKUIDelegate {
}
}
}
var article: Article? {
switch state {
case .article(let article):
return article
case .extracted(let article, _):
return article
default:
return nil
}
}
#if !MAC_APP_STORE
private var webInspectorEnabled: Bool {
@ -193,7 +204,8 @@ struct TemplateData: Codable {
private extension DetailWebViewController {
func reloadArticleImage() {
webView.evaluateJavaScript("reloadArticleImage()")
guard let article = article else { return }
webView?.evaluateJavaScript("reloadArticleImage(\"\(article.articleID)\")")
}
func reloadHTML() {

View File

@ -79,9 +79,9 @@ function flattenPreElements() {
ElementUnwrapper.unwrapAppropriateChildren("div.articleBody td > pre");
}
function reloadArticleImage() {
function reloadArticleImage(articleID) {
var image = document.getElementById("nnwImageIcon");
image.src = "nnwImageIcon://";
image.src = "nnwImageIcon://" + articleID;
}
function error() {

View File

@ -512,7 +512,8 @@ private extension WebViewController {
}
func reloadArticleImage() {
webView?.evaluateJavaScript("reloadArticleImage()")
guard let article = article else { return }
webView?.evaluateJavaScript("reloadArticleImage(\"\(article.articleID)\")")
}
func imageWasClicked(body: String?) {