From 7b02e10cd5484c48a678f3c12f12d063727c8529 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Mon, 15 Jul 2019 20:38:18 -0700 Subject: [PATCH] Multifile support in ImageCommon.error. #2171 --- src/Images/Gallery.coffee | 4 +++- src/Images/ImageCommon.coffee | 12 ++++++------ src/Images/ImageExpand.coffee | 2 +- src/Images/ImageHover.coffee | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Images/Gallery.coffee b/src/Images/Gallery.coffee index d5c681d65..34f90f628 100644 --- a/src/Images/Gallery.coffee +++ b/src/Images/Gallery.coffee @@ -195,7 +195,9 @@ Gallery = if @error?.code is MediaError.MEDIA_ERR_DECODE return new Notice 'error', 'Corrupt or unplayable video', 30 return if ImageCommon.isFromArchive @ - ImageCommon.error @, g.posts[@dataset.post], null, (url) => + post = g.posts[@dataset.post] + file = post.file + ImageCommon.error @, post, file, null, (url) => return unless url Gallery.images[@dataset.id].href = url (@src = url if Gallery.nodes.current is @) diff --git a/src/Images/ImageCommon.coffee b/src/Images/ImageCommon.coffee index 5f1f05810..358e117ef 100644 --- a/src/Images/ImageCommon.coffee +++ b/src/Images/ImageCommon.coffee @@ -36,8 +36,8 @@ ImageCommon = isFromArchive: (file) -> g.SITE.software is 'yotsuba' and !ImageHost.test(file.src.split('/')[2]) - error: (file, post, delay, cb) -> - src = post.file.url.split '/' + error: (file, post, fileObj, delay, cb) -> + src = fileObj.url.split '/' url = null if g.SITE.software is 'yotsuba' and Conf['404 Redirect'] url = Redirect.to 'file', { @@ -46,10 +46,10 @@ ImageCommon = } url = null unless url and Redirect.securityCheck(url) - return cb url if (post.isDead or post.file.isDead) and not ImageCommon.isFromArchive(file) + return cb url if (post.isDead or fileObj.isDead) and not ImageCommon.isFromArchive(file) timeoutID = setTimeout (-> cb url), delay if delay? - return if post.isDead or post.file.isDead + return if post.isDead or fileObj.isDead redirect = -> unless ImageCommon.isFromArchive file clearTimeout timeoutID if delay? @@ -65,11 +65,11 @@ ImageCommon = if postObj.no isnt post.ID post.kill() redirect() - else if postObj.filedeleted + else if fileObj.docIndex in g.SITE.Build.parseJSON(postObj, post.board).filesDeleted post.kill true redirect() else - url = post.file.url + url = fileObj.url # Add controls, but not until the mouse is moved over the video. addControls: (video) -> diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index 20a749167..87ff8a71c 100644 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -272,7 +272,7 @@ ImageExpand = # Don't autoretry images from the archive. if ImageCommon.isFromArchive @ return ImageExpand.contract post - ImageCommon.error @, post, 10 * $.SECOND, (URL) -> + ImageCommon.error @, post, post.file, 10 * $.SECOND, (URL) -> if post.file.isExpanding or post.file.isExpanded ImageExpand.contract post (ImageExpand.expand post, URL if URL) diff --git a/src/Images/ImageHover.coffee b/src/Images/ImageHover.coffee index 68c1e227f..29eb4db23 100644 --- a/src/Images/ImageHover.coffee +++ b/src/Images/ImageHover.coffee @@ -71,7 +71,7 @@ ImageHover = error: (post, file) -> -> return if ImageCommon.decodeError @, file - ImageCommon.error @, post, 3 * $.SECOND, (URL) => + ImageCommon.error @, post, file, 3 * $.SECOND, (URL) => if URL @src = URL + if @src is URL then '?' + Date.now() else '' else