remove stale requests from cache on index refresh

This commit is contained in:
ccd0 2014-08-29 22:22:37 -07:00
parent 4cc724cee4
commit 5c46064306
2 changed files with 7 additions and 2 deletions

View File

@ -289,6 +289,7 @@ Index =
Index.scrollToIndex()
parse: (pages, pageNum) ->
$.cleanCache (url) -> /^\/\/a\.4cdn\.org\//.test url
Index.parseThreadList pages
Index.buildThreads()
Index.sort()

View File

@ -72,9 +72,9 @@ $.ajax = do ->
r.send form
r
$.cache = do ->
do ->
reqs = {}
(url, cb, options) ->
$.cache = (url, cb, options) ->
if req = reqs[url]
if req.readyState is 4
cb.call req, req.evt
@ -93,6 +93,10 @@ $.cache = do ->
$.on req, 'abort error', rm
req.callbacks = [cb]
reqs[url] = req
$.cleanCache = (testf) ->
for url of reqs when testf url
delete reqs[url]
return
$.cb =
checked: ->