Cache requests to threads.json.

This commit is contained in:
Nicolas Stepien 2013-04-05 00:16:42 +02:00
parent cd82bce655
commit c79bb318b2
3 changed files with 5 additions and 5 deletions

View File

@ -63,8 +63,8 @@ $.extend $,
return
rm = -> delete reqs[url]
req = $.ajax url,
onload: ->
cb.call @ for cb in @callbacks
onload: (e) ->
cb.call @, e for cb in @callbacks
delete @callbacks
onabort: rm
onerror: rm

View File

@ -64,7 +64,7 @@ class DataBoard
$.set @key, @data
ajaxClean: (boardID) ->
$.ajax "//api.4chan.org/#{boardID}/threads.json", onload: (e) =>
$.cache "//api.4chan.org/#{boardID}/threads.json", (e) =>
if e.target.status is 404
# Deleted board.
@delete boardID

View File

@ -1111,10 +1111,10 @@ ThreadHiding =
# We need to clean hidden threads on the catalog ourselves,
# otherwise if we don't visit the catalog regularly
# it will pollute the localStorage and our data.
$.ajax "//api.4chan.org/#{g.BOARD}/threads.json", onload: (e) ->
$.cache "//api.4chan.org/#{g.BOARD}/threads.json", ->
return unless @status is 200
threads = {}
for page in JSON.parse e.target.response
for page in JSON.parse @response
for thread in page.threads
if thread.no of hiddenThreadsOnCatalog
threads[thread.no] = hiddenThreadsOnCatalog[thread.no]