Work around delayed thread creation issue. #362
This commit is contained in:
parent
b9c440de4a
commit
6968bbac81
@ -762,13 +762,33 @@ QR =
|
|||||||
"#{window.location.origin}/#{g.BOARD}/thread/#{threadID}#p#{postID}"
|
"#{window.location.origin}/#{g.BOARD}/thread/#{threadID}#p#{postID}"
|
||||||
|
|
||||||
if URL
|
if URL
|
||||||
if Conf['Open Post in New Tab'] or postsCount
|
open = if Conf['Open Post in New Tab'] or postsCount
|
||||||
$.open URL
|
-> $.open URL
|
||||||
else
|
else
|
||||||
window.location = URL
|
-> window.location = URL
|
||||||
|
|
||||||
|
if threadID is postID
|
||||||
|
# XXX 4chan sometimes responds before the thread exists.
|
||||||
|
QR.waitForThread URL, open
|
||||||
|
else
|
||||||
|
open()
|
||||||
|
|
||||||
QR.status()
|
QR.status()
|
||||||
|
|
||||||
|
waitForThread: (url, cb) ->
|
||||||
|
attempts = 0
|
||||||
|
check = ->
|
||||||
|
$.ajax url,
|
||||||
|
onloadend: ->
|
||||||
|
attempts++
|
||||||
|
if attempts >= 5 or @status is 200
|
||||||
|
cb()
|
||||||
|
else
|
||||||
|
setTimeout check, attempts * $.SECOND
|
||||||
|
,
|
||||||
|
type: 'HEAD'
|
||||||
|
check()
|
||||||
|
|
||||||
abort: ->
|
abort: ->
|
||||||
if QR.req and !QR.req.isUploadFinished
|
if QR.req and !QR.req.isUploadFinished
|
||||||
QR.req.abort()
|
QR.req.abort()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user