Fix thread watcher/expansion/hiding buttons after an index refresh.

This commit is contained in:
Mayhem 2013-10-30 04:32:31 +01:00
parent 43567173fc
commit 11c3b0018a
3 changed files with 10 additions and 1 deletions

View File

@ -2,6 +2,8 @@ ExpandThread =
init: ->
return if g.VIEW isnt 'index' or !Conf['Thread Expansion']
$.on d, 'IndexRefresh', @onrefresh
Thread.callbacks.push
name: 'Thread Expansion'
cb: @node
@ -15,6 +17,11 @@ ExpandThread =
$.on a, 'click', ExpandThread.cbToggle
$.replace span, a
onrefresh: ->
for threadID, thread of g.BOARD.threads
ExpandThread.node.call thread
return
text: (status, posts, files) ->
text = [status]
text.push "#{posts} post#{if posts > 1 then 's' else ''}"

View File

@ -83,7 +83,7 @@ Index =
nodes.push threadRoot, $.el 'hr'
unless thread = g.threads["#{g.BOARD}.#{data.no}"]
thread = new Thread data.no, g.BOARD
threads.push thread
threads.push thread
for postRoot in $$ '.thread > .postContainer', threadRoot
continue if thread.posts[postRoot.id.match /\d+/]
try
@ -104,3 +104,4 @@ Index =
$.rmAll board
$.add board, nodes
$('.pagelist').hidden = Conf['Index Mode'] isnt 'paged'
$.event 'IndexRefresh'

View File

@ -12,6 +12,7 @@ ThreadWatcher =
$.on d, 'QRPostSuccessful', @cb.post
$.on d, 'ThreadUpdate', @cb.threadUpdate if g.VIEW is 'thread'
$.on d, '4chanXInitFinished', @ready
$.on d, 'IndexRefresh', @refresh
now = Date.now()
if (@db.data.lastChecked or 0) < now - 2 * $.HOUR