Do auto-checking when last check timestamp is from the future or a non-number. #1164

This commit is contained in:
ccd0 2016-10-30 19:53:26 -07:00
parent e442da202a
commit bc3099caa7
4 changed files with 7 additions and 4 deletions

View File

@ -9,7 +9,9 @@ Redirect =
init: -> init: ->
@selectArchives() @selectArchives()
@update() if Conf['archiveAutoUpdate'] and Conf['lastarchivecheck'] < Date.now() - 2 * $.DAY if Conf['archiveAutoUpdate']
now = Date.now()
@update() unless now - 2 * $.DAY < Conf['lastarchivecheck'] <= now
selectArchives: -> selectArchives: ->
o = o =

View File

@ -2,7 +2,8 @@ BoardConfig =
cbs: [] cbs: []
init: -> init: ->
if (Conf['boardConfig'].lastChecked or 0) < Date.now() - 2 * $.HOUR now = Date.now()
unless now - 2 * $.HOUR < (Conf['boardConfig'].lastChecked or 0) <= now
$.ajax '//a.4cdn.org/boards.json', $.ajax '//a.4cdn.org/boards.json',
onloadend: @load onloadend: @load
else else

View File

@ -178,7 +178,7 @@ ThreadWatcher =
{db} = ThreadWatcher {db} = ThreadWatcher
interval = if ThreadWatcher.unreadEnabled and Conf['Show Unread Count'] then 5 * $.MINUTE else 2 * $.HOUR interval = if ThreadWatcher.unreadEnabled and Conf['Show Unread Count'] then 5 * $.MINUTE else 2 * $.HOUR
now = Date.now() now = Date.now()
if now >= (db.data.lastChecked or 0) + interval unless now - interval < (db.data.lastChecked or 0) <= now
ThreadWatcher.fetchAllStatus() # calls forceSync ThreadWatcher.fetchAllStatus() # calls forceSync
db.data.lastChecked = now db.data.lastChecked = now
db.save() db.save()

View File

@ -84,7 +84,7 @@ class DataBoard
@deleteIfEmpty {boardID} @deleteIfEmpty {boardID}
now = Date.now() now = Date.now()
if (@data.lastChecked or 0) < now - 2 * $.HOUR unless now - 2 * $.HOUR < (@data.lastChecked or 0) <= now
@data.lastChecked = now @data.lastChecked = now
for boardID of @data.boards for boardID of @data.boards
@ajaxClean boardID @ajaxClean boardID