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() Index.scrollToIndex()
parse: (pages, pageNum) -> parse: (pages, pageNum) ->
$.cleanCache (url) -> /^\/\/a\.4cdn\.org\//.test url
Index.parseThreadList pages Index.parseThreadList pages
Index.buildThreads() Index.buildThreads()
Index.sort() Index.sort()

View File

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