Cache requests to threads.json.
This commit is contained in:
parent
cd82bce655
commit
c79bb318b2
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user