image error handling fixes
This commit is contained in:
parent
61ebff6d6b
commit
5e2ccfee2d
@ -8,8 +8,7 @@ ImageCommon =
|
|||||||
return true
|
return true
|
||||||
|
|
||||||
error: (file, post, delay, cb) ->
|
error: (file, post, delay, cb) ->
|
||||||
return cb null unless file.src.split('/')[2] is 'i.4cdn.org'
|
return ImageCommon.retry post, cb if (post.isDead or post.file.isDead) and file.src.split('/')[2] is 'i.4cdn.org'
|
||||||
return ImageCommon.retry post, cb if post.isDead or post.file.isDead
|
|
||||||
|
|
||||||
timeoutID = setTimeout ImageCommon.retry, delay, post, cb if delay?
|
timeoutID = setTimeout ImageCommon.retry, delay, post, cb if delay?
|
||||||
return if post.isDead or post.file.isDead
|
return if post.isDead or post.file.isDead
|
||||||
@ -40,7 +39,7 @@ ImageCommon =
|
|||||||
|
|
||||||
retry: (post, cb) ->
|
retry: (post, cb) ->
|
||||||
unless post.isDead or post.file.isDead
|
unless post.isDead or post.file.isDead
|
||||||
return cb post.file.URL + '?' + Date.now()
|
return cb post.file.URL
|
||||||
src = post.file.URL.split '/'
|
src = post.file.URL.split '/'
|
||||||
URL = Redirect.to 'file',
|
URL = Redirect.to 'file',
|
||||||
boardID: post.board.ID
|
boardID: post.board.ID
|
||||||
|
|||||||
@ -245,18 +245,20 @@ ImageExpand =
|
|||||||
post = Get.postFromNode @
|
post = Get.postFromNode @
|
||||||
$.rm @
|
$.rm @
|
||||||
delete post.file.fullImage
|
delete post.file.fullImage
|
||||||
if ImageCommon.decodeError @, post
|
|
||||||
ImageExpand.contract post
|
|
||||||
return
|
|
||||||
# Images can error:
|
# Images can error:
|
||||||
# - before the image started loading.
|
# - before the image started loading.
|
||||||
# - after the image started loading.
|
# - after the image started loading.
|
||||||
# Don't try to re-expand if it was already contracted.
|
# Don't try to re-expand if it was already contracted.
|
||||||
if post.file.isExpanding or post.file.isExpanded
|
return unless post.file.isExpanding or post.file.isExpanded
|
||||||
ImageCommon.error @, post, 10 * $.SECOND, (URL) ->
|
if ImageCommon.decodeError @, post
|
||||||
if post.file.isExpanding or post.file.isExpanded
|
return ImageExpand.contract post
|
||||||
ImageExpand.contract post
|
# Don't autoretry images from the archive.
|
||||||
ImageExpand.expand post, URL if URL
|
unless @src.split('/')[2] is 'i.4cdn.org'
|
||||||
|
return ImageExpand.contract post
|
||||||
|
ImageCommon.error @, post, 10 * $.SECOND, (URL) ->
|
||||||
|
if post.file.isExpanding or post.file.isExpanded
|
||||||
|
ImageExpand.contract post
|
||||||
|
ImageExpand.expand post, URL if URL
|
||||||
|
|
||||||
menu:
|
menu:
|
||||||
init: ->
|
init: ->
|
||||||
|
|||||||
@ -12,6 +12,7 @@ ImageHover =
|
|||||||
post = Get.postFromNode @
|
post = Get.postFromNode @
|
||||||
{file} = post
|
{file} = post
|
||||||
{isVideo} = file
|
{isVideo} = file
|
||||||
|
return if post.file.isExpanding or post.file.isExpanded
|
||||||
if el = file.fullImage
|
if el = file.fullImage
|
||||||
el.id = 'ihover'
|
el.id = 'ihover'
|
||||||
TrashQueue.remove el
|
TrashQueue.remove el
|
||||||
@ -19,7 +20,6 @@ ImageHover =
|
|||||||
file.fullImage = el = $.el (if isVideo then 'video' else 'img'),
|
file.fullImage = el = $.el (if isVideo then 'video' else 'img'),
|
||||||
className: 'full-image'
|
className: 'full-image'
|
||||||
id: 'ihover'
|
id: 'ihover'
|
||||||
el.dataset.fullID = post.fullID
|
|
||||||
$.on el, 'error', ImageHover.error
|
$.on el, 'error', ImageHover.error
|
||||||
el.src = file.URL
|
el.src = file.URL
|
||||||
$.after file.thumb, el
|
$.after file.thumb, el
|
||||||
@ -35,13 +35,19 @@ ImageHover =
|
|||||||
asapTest: -> (if isVideo then el.readyState >= el.HAVE_CURRENT_DATA else el.naturalHeight)
|
asapTest: -> (if isVideo then el.readyState >= el.HAVE_CURRENT_DATA else el.naturalHeight)
|
||||||
noRemove: true
|
noRemove: true
|
||||||
cb: ->
|
cb: ->
|
||||||
$.off el, 'error', ImageHover.error
|
|
||||||
if isVideo
|
if isVideo
|
||||||
el.pause()
|
el.pause()
|
||||||
TrashQueue.add el, post
|
TrashQueue.add el, post
|
||||||
el.removeAttribute 'id'
|
el.removeAttribute 'id'
|
||||||
error: ->
|
error: ->
|
||||||
return unless doc.contains @
|
post = Get.postFromNode @
|
||||||
post = g.posts[@dataset.fullID]
|
return if post.file.isExpanding or post.file.isExpanded
|
||||||
return if ImageCommon.decodeError @, post
|
if @id is 'ihover' # still hovering
|
||||||
ImageCommon.error @, post, 3 * $.SECOND, (URL) => @src = URL if URL
|
return if ImageCommon.decodeError @, post
|
||||||
|
ImageCommon.error @, post, 3 * $.SECOND, (URL) =>
|
||||||
|
if URL
|
||||||
|
@src = URL + if @src is URL then '?' + Date.now() else ''
|
||||||
|
else
|
||||||
|
$.off @, 'error', ImageHover.error
|
||||||
|
$.rm @
|
||||||
|
delete post.file.fullImage
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user