diff --git a/src/Posting/Captcha.cache.coffee b/src/Posting/Captcha.cache.coffee index 4b8a78a68..05cacf078 100644 --- a/src/Posting/Captcha.cache.coffee +++ b/src/Posting/Captcha.cache.coffee @@ -21,9 +21,11 @@ Captcha.cache = @captchas = captchas @count() - getOne: -> + getOne: (isReply) -> @clear() - if (captcha = @captchas.shift()) + i = @captchas.findIndex((x) -> isReply or !x.challenge?) + if i >= 0 + captcha = @captchas.splice(i, 1)[0] $.set 'captchas', @captchas @count() captcha diff --git a/src/Posting/Captcha.v1.coffee b/src/Posting/Captcha.v1.coffee index f158833cc..032fba5cc 100644 --- a/src/Posting/Captcha.v1.coffee +++ b/src/Posting/Captcha.v1.coffee @@ -134,8 +134,8 @@ Captcha.v1 = delete @occupied @beforeSetup() if @nodes - getOne: -> - if (captcha = Captcha.cache.getOne()) + getOne: (isReply) -> + if (captcha = Captcha.cache.getOne isReply) captcha else challenge = @nodes.img.alt diff --git a/src/Posting/Captcha.v2.coffee b/src/Posting/Captcha.v2.coffee index a36fb21b7..f6bc6f075 100644 --- a/src/Posting/Captcha.v2.coffee +++ b/src/Posting/Captcha.v2.coffee @@ -153,8 +153,8 @@ Captcha.v2 = $.rm node return - getOne: -> - Captcha.cache.getOne() + getOne: (isReply) -> + Captcha.cache.getOne isReply save: (pasted, token) -> Captcha.cache.save diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index c02bd2fca..eee494449 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -621,7 +621,7 @@ QR = err or= 'Original comment required.' if QR.captcha.isEnabled and !err - captcha = QR.captcha.getOne() + captcha = QR.captcha.getOne(!!threadID) unless captcha err = 'No valid captcha.' QR.captcha.setup(!QR.cooldown.auto or d.activeElement is QR.nodes.status)