Fix retry logic for page count.
This commit is contained in:
parent
f321323865
commit
76f6226729
@ -54,7 +54,7 @@ ThreadStats =
|
|||||||
return unless Conf["Page Count in Stats"]
|
return unless Conf["Page Count in Stats"]
|
||||||
if newPosts.length
|
if newPosts.length
|
||||||
ThreadStats.lastPost = g.posts[newPosts[newPosts.length - 1]].info.date
|
ThreadStats.lastPost = g.posts[newPosts[newPosts.length - 1]].info.date
|
||||||
if ThreadStats.lastPost > ThreadStats.lastPageUpdate and ThreadStats.pageCountEl?.textContent isnt '1'
|
if ThreadStats.pageCountEl?.textContent isnt '1'
|
||||||
ThreadStats.fetchPage()
|
ThreadStats.fetchPage()
|
||||||
|
|
||||||
update: (postCount, fileCount, ipCount) ->
|
update: (postCount, fileCount, ipCount) ->
|
||||||
@ -78,11 +78,20 @@ ThreadStats =
|
|||||||
whenModified: 'ThreadStats'
|
whenModified: 'ThreadStats'
|
||||||
|
|
||||||
onThreadsLoad: ->
|
onThreadsLoad: ->
|
||||||
return unless Conf["Page Count in Stats"] and @status is 200
|
return unless Conf["Page Count in Stats"]
|
||||||
for page in @response
|
if @status is 200
|
||||||
for thread in page.threads when thread.no is ThreadStats.thread.ID
|
for page in @response
|
||||||
ThreadStats.pageCountEl.textContent = page.page
|
for thread in page.threads when thread.no is ThreadStats.thread.ID
|
||||||
(if page.page is @response.length then $.addClass else $.rmClass) ThreadStats.pageCountEl, 'warning'
|
ThreadStats.pageCountEl.textContent = page.page
|
||||||
# Thread data may be stale (modification date given < time of last post). If so, try again on next thread update.
|
(if page.page is @response.length then $.addClass else $.rmClass) ThreadStats.pageCountEl, 'warning'
|
||||||
ThreadStats.lastPageUpdate = new Date thread.last_modified * $.SECOND
|
ThreadStats.lastPageUpdate = new Date thread.last_modified * $.SECOND
|
||||||
return
|
ThreadStats.retry()
|
||||||
|
return
|
||||||
|
else if @status is 304
|
||||||
|
ThreadStats.retry()
|
||||||
|
|
||||||
|
retry: ->
|
||||||
|
# If thread data is stale (modification date given < time of last post), try again.
|
||||||
|
if ThreadStats.lastPost > ThreadStats.lastPageUpdate and ThreadStats.pageCountEl?.textContent isnt '1'
|
||||||
|
clearTimeout ThreadStats.timeout
|
||||||
|
ThreadStats.timeout = setTimeout ThreadStats.fetchPage, 5 * $.SECOND
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user