Consolidate code to test whether image has been redirected to archive yet.
This commit is contained in:
parent
9ff30e39a7
commit
645301f263
@ -194,7 +194,7 @@ Gallery =
|
|||||||
error: ->
|
error: ->
|
||||||
if @error?.code is MediaError.MEDIA_ERR_DECODE
|
if @error?.code is MediaError.MEDIA_ERR_DECODE
|
||||||
return new Notice 'error', 'Corrupt or unplayable video', 30
|
return new Notice 'error', 'Corrupt or unplayable video', 30
|
||||||
return unless @src.split('/')[2] is 'i.4cdn.org'
|
return if ImageCommon.isFromArchive @
|
||||||
ImageCommon.error @, g.posts[@dataset.post], null, (url) =>
|
ImageCommon.error @, g.posts[@dataset.post], null, (url) =>
|
||||||
return unless url
|
return unless url
|
||||||
Gallery.images[@dataset.id].href = url
|
Gallery.images[@dataset.id].href = url
|
||||||
|
|||||||
@ -33,6 +33,9 @@ ImageCommon =
|
|||||||
message.textContent = 'Error: Corrupt or unplayable video'
|
message.textContent = 'Error: Corrupt or unplayable video'
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
isFromArchive: (file) ->
|
||||||
|
file.src.split('/')[2] isnt 'i.4cdn.org'
|
||||||
|
|
||||||
error: (file, post, delay, cb) ->
|
error: (file, post, delay, cb) ->
|
||||||
src = post.file.url.split '/'
|
src = post.file.url.split '/'
|
||||||
URL = Redirect.to 'file', {
|
URL = Redirect.to 'file', {
|
||||||
@ -42,12 +45,12 @@ ImageCommon =
|
|||||||
unless Conf['404 Redirect'] and URL and Redirect.securityCheck URL
|
unless Conf['404 Redirect'] and URL and Redirect.securityCheck URL
|
||||||
URL = null
|
URL = null
|
||||||
|
|
||||||
return cb URL if (post.isDead or post.file.isDead) and file.src.split('/')[2] is 'i.4cdn.org'
|
return cb URL if (post.isDead or post.file.isDead) and not ImageCommon.isFromArchive file
|
||||||
|
|
||||||
timeoutID = setTimeout (-> cb URL), delay if delay?
|
timeoutID = setTimeout (-> cb URL), delay if delay?
|
||||||
return if post.isDead or post.file.isDead
|
return if post.isDead or post.file.isDead
|
||||||
redirect = ->
|
redirect = ->
|
||||||
if file.src.split('/')[2] is 'i.4cdn.org'
|
unless ImageCommon.isFromArchive file
|
||||||
clearTimeout timeoutID if delay?
|
clearTimeout timeoutID if delay?
|
||||||
cb URL
|
cb URL
|
||||||
|
|
||||||
|
|||||||
@ -268,7 +268,7 @@ ImageExpand =
|
|||||||
if ImageCommon.decodeError @, post
|
if ImageCommon.decodeError @, post
|
||||||
return ImageExpand.contract post
|
return ImageExpand.contract post
|
||||||
# Don't autoretry images from the archive.
|
# Don't autoretry images from the archive.
|
||||||
unless @src.split('/')[2] is 'i.4cdn.org'
|
if ImageCommon.isFromArchive @
|
||||||
return ImageExpand.contract post
|
return ImageExpand.contract post
|
||||||
ImageCommon.error @, post, 10 * $.SECOND, (URL) ->
|
ImageCommon.error @, post, 10 * $.SECOND, (URL) ->
|
||||||
if post.file.isExpanding or post.file.isExpanded
|
if post.file.isExpanding or post.file.isExpanded
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user