Cache requests to threads.json.
This commit is contained in:
parent
cd82bce655
commit
c79bb318b2
@ -63,8 +63,8 @@ $.extend $,
|
|||||||
return
|
return
|
||||||
rm = -> delete reqs[url]
|
rm = -> delete reqs[url]
|
||||||
req = $.ajax url,
|
req = $.ajax url,
|
||||||
onload: ->
|
onload: (e) ->
|
||||||
cb.call @ for cb in @callbacks
|
cb.call @, e for cb in @callbacks
|
||||||
delete @callbacks
|
delete @callbacks
|
||||||
onabort: rm
|
onabort: rm
|
||||||
onerror: rm
|
onerror: rm
|
||||||
|
|||||||
@ -64,7 +64,7 @@ class DataBoard
|
|||||||
|
|
||||||
$.set @key, @data
|
$.set @key, @data
|
||||||
ajaxClean: (boardID) ->
|
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
|
if e.target.status is 404
|
||||||
# Deleted board.
|
# Deleted board.
|
||||||
@delete boardID
|
@delete boardID
|
||||||
|
|||||||
@ -1111,10 +1111,10 @@ ThreadHiding =
|
|||||||
# We need to clean hidden threads on the catalog ourselves,
|
# We need to clean hidden threads on the catalog ourselves,
|
||||||
# otherwise if we don't visit the catalog regularly
|
# otherwise if we don't visit the catalog regularly
|
||||||
# it will pollute the localStorage and our data.
|
# 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
|
return unless @status is 200
|
||||||
threads = {}
|
threads = {}
|
||||||
for page in JSON.parse e.target.response
|
for page in JSON.parse @response
|
||||||
for thread in page.threads
|
for thread in page.threads
|
||||||
if thread.no of hiddenThreadsOnCatalog
|
if thread.no of hiddenThreadsOnCatalog
|
||||||
threads[thread.no] = hiddenThreadsOnCatalog[thread.no]
|
threads[thread.no] = hiddenThreadsOnCatalog[thread.no]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user