Fix QR.cooldown data not being set up when called from DeleteLink.

This commit is contained in:
ccd0 2015-08-07 21:44:36 -07:00
parent 9a0447177f
commit 779aa10e9c
4 changed files with 19 additions and 10 deletions

View File

@ -51,6 +51,7 @@ Main =
for db in DataBoard.keys
Conf[db] = boards: {}
Conf['selectedArchives'] = {}
Conf['cooldowns'] = {}
$.get Conf, (items) ->
$.extend Conf, items
@ -338,6 +339,7 @@ Main =
['Recursive', Recursive]
['Strike-through Quotes', QuoteStrikeThrough]
['Quick Reply', QR]
['Cooldown', QR.cooldown]
['Menu', Menu]
['Index Generator (Menu)', Index.menu]
['Report Link', ReportLink]

View File

@ -524,7 +524,7 @@ $.clear = (cb) ->
# XXX https://github.com/greasemonkey/greasemonkey/issues/2033
# Also support case where GM_listValues is not defined.
$.delete Object.keys(Conf)
$.delete ['previousversion', 'AutoWatch', 'cooldowns', 'QR Size', 'captchas', 'QR.persona', 'hiddenPSA']
$.delete ['previousversion', 'AutoWatch', 'QR Size', 'captchas', 'QR.persona', 'hiddenPSA']
$.delete ("#{id}.position" for id in ['embedding', 'updater', 'thread-stats', 'thread-watcher', 'qr'])
try
$.delete $.listValues().map (key) -> key.replace g.NAMESPACE, ''

View File

@ -565,7 +565,7 @@ QR =
QR.persona.init()
new QR.post true
QR.status()
QR.cooldown.init()
QR.cooldown.setup()
QR.captcha.init()
$.add d.body, dialog

View File

@ -1,7 +1,14 @@
QR.cooldown =
seconds: 0
# Called from Main
init: ->
return unless Conf['Quick Reply'] and Conf['Cooldown']
@data = Conf['cooldowns']
$.sync 'cooldowns', @sync
# Called from QR
setup: ->
return unless Conf['Cooldown']
# Read cooldown times
@ -18,17 +25,17 @@ QR.cooldown =
# There is a 300 second inter-board thread cooldown.
QR.cooldown.delays['thread_global'] = 300
# Retrieve recent posts and delays.
$.get 'cooldowns', {}, ({cooldowns}) ->
QR.cooldown.data = cooldowns
QR.cooldown.start()
$.sync 'cooldowns', QR.cooldown.sync
QR.cooldown.start()
start: ->
{data} = QR.cooldown
unless QR.cooldown.isCounting or Object.keys(data[g.BOARD.ID] or {}).length + Object.keys(data.global or {}).length is 0
QR.cooldown.isCounting = true
QR.cooldown.count()
return unless (
QR.cooldown.delays and
!QR.cooldown.isCounting and
Object.keys(data[g.BOARD.ID] or {}).length + Object.keys(data.global or {}).length > 0
)
QR.cooldown.isCounting = true
QR.cooldown.count()
sync: (data) ->
QR.cooldown.data = data or {}