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

View File

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

View File

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

View File

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