$.ajax: Each feature gets its own last-modified list.

This commit is contained in:
ccd0 2015-05-25 18:44:13 -07:00
parent e15883c5cb
commit cd23973d99
4 changed files with 5 additions and 5 deletions

View File

@ -431,7 +431,7 @@ Index =
Index.req = $.ajax "//a.4cdn.org/#{g.BOARD}/catalog.json",
onloadend: (e) -> Index.load e, state
,
whenModified: true
whenModified: 'Index'
$.addClass Index.button, 'fa-spin'
load: (e, state) ->

View File

@ -64,8 +64,8 @@ $.ajax = do ->
options.onerror?()
return
if whenModified
r.setRequestHeader 'If-Modified-Since', lastModified[url] if url of lastModified
$.on r, 'load', -> lastModified[url] = r.getResponseHeader 'Last-Modified'
r.setRequestHeader 'If-Modified-Since', lastModified[whenModified][url] if lastModified[whenModified]?[url]?
$.on r, 'load', -> (lastModified[whenModified] or= {})[url] = r.getResponseHeader 'Last-Modified'
if /\.json$/.test url
r.responseType = 'json'
$.extend r, options

View File

@ -75,7 +75,7 @@ ThreadStats =
return
ThreadStats.timeout = setTimeout ThreadStats.fetchPage, 2 * $.MINUTE
$.ajax "//a.4cdn.org/#{ThreadStats.thread.board}/threads.json", onload: ThreadStats.onThreadsLoad,
whenModified: true
whenModified: 'ThreadStats'
onThreadsLoad: ->
return unless Conf["Page Count in Stats"] and @status is 200

View File

@ -241,7 +241,7 @@ ThreadUpdater =
onloadend: ThreadUpdater.cb.load
timeout: $.MINUTE
,
whenModified: true
whenModified: 'ThreadUpdater'
updateThreadStatus: (type, status) ->
return unless hasChanged = ThreadUpdater.thread["is#{type}"] isnt status