Leave caching and conditional requests to the browser. Store last fetched post to skip needless rescans.
This commit is contained in:
parent
b4ffb42a33
commit
ad16e13b61
@ -224,8 +224,6 @@ ThreadWatcher =
|
|||||||
onloadend: ->
|
onloadend: ->
|
||||||
ThreadWatcher.parseStatus.call @, thread
|
ThreadWatcher.parseStatus.call @, thread
|
||||||
timeout: $.MINUTE
|
timeout: $.MINUTE
|
||||||
,
|
|
||||||
whenModified: if force then false else 'ThreadWatcher'
|
|
||||||
ThreadWatcher.requests.push req
|
ThreadWatcher.requests.push req
|
||||||
|
|
||||||
parseStatus: ({boardID, threadID, data}) ->
|
parseStatus: ({boardID, threadID, data}) ->
|
||||||
@ -236,12 +234,15 @@ ThreadWatcher =
|
|||||||
ThreadWatcher.status.textContent = "#{Math.round(ThreadWatcher.fetched / ThreadWatcher.requests.length * 100)}%"
|
ThreadWatcher.status.textContent = "#{Math.round(ThreadWatcher.fetched / ThreadWatcher.requests.length * 100)}%"
|
||||||
|
|
||||||
if @status is 200 and @response
|
if @status is 200 and @response
|
||||||
|
last = @response.posts[@response.posts.length-1].no
|
||||||
isDead = !!@response.posts[0].archived
|
isDead = !!@response.posts[0].archived
|
||||||
if isDead and Conf['Auto Prune']
|
if isDead and Conf['Auto Prune']
|
||||||
ThreadWatcher.db.delete {boardID, threadID}
|
ThreadWatcher.db.delete {boardID, threadID}
|
||||||
ThreadWatcher.refresh()
|
ThreadWatcher.refresh()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
return if last is data.last and isDead is data.isDead
|
||||||
|
|
||||||
lastReadPost = ThreadWatcher.unreaddb.get
|
lastReadPost = ThreadWatcher.unreaddb.get
|
||||||
boardID: boardID
|
boardID: boardID
|
||||||
threadID: threadID
|
threadID: threadID
|
||||||
@ -276,9 +277,9 @@ ThreadWatcher =
|
|||||||
if quotesYou and not Filter.isHidden(Build.parseJSON postObj, boardID)
|
if quotesYou and not Filter.isHidden(Build.parseJSON postObj, boardID)
|
||||||
quotingYou = true
|
quotingYou = true
|
||||||
|
|
||||||
if isDead isnt data.isDead or unread isnt data.unread or quotingYou isnt data.quotingYou
|
updated = (isDead isnt data.isDead or unread isnt data.unread or quotingYou isnt data.quotingYou)
|
||||||
ThreadWatcher.db.extend {boardID, threadID, val: {isDead, unread, quotingYou}}
|
ThreadWatcher.db.extend {boardID, threadID, val: {last, isDead, unread, quotingYou}}
|
||||||
ThreadWatcher.refresh()
|
ThreadWatcher.refresh() if updated
|
||||||
|
|
||||||
else if @status is 404
|
else if @status is 404
|
||||||
if Conf['Auto Prune']
|
if Conf['Auto Prune']
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user