More index tweaking/optimization and small thread hiding fix.
Most feature that need to be called on each index refresh don't need to be called on every single page build, but only after building the threads. ThreadHiding needs to be fired on each page build to ensure that the stub summaries fit with the number of replies, so it has to wait for the last replies to be added. This also fixes the bug where ThreadHiding was creating one extra stub on each IndexRefresh event.
This commit is contained in:
parent
8f56d3e415
commit
f09121ab2e
@ -4,7 +4,7 @@ ThreadHiding =
|
||||
|
||||
@db = new DataBoard 'hiddenThreads'
|
||||
@syncCatalog()
|
||||
$.on d, 'IndexRefresh', @onrefresh
|
||||
$.on d, 'IndexBuild', @onIndexBuild
|
||||
Thread.callbacks.push
|
||||
name: 'Thread Hiding'
|
||||
cb: @node
|
||||
@ -15,13 +15,15 @@ ThreadHiding =
|
||||
return unless Conf['Thread Hiding']
|
||||
$.prepend @OP.nodes.root, ThreadHiding.makeButton @, 'hide'
|
||||
|
||||
onrefresh: ->
|
||||
for threadID, thread of g.BOARD.threads when thread.isHidden
|
||||
root = thread.OP.nodes.root.parentNode
|
||||
if thread.stub
|
||||
onIndexBuild: ({detail: nodes}) ->
|
||||
for root, i in nodes by 2
|
||||
thread = Get.threadFromRoot root
|
||||
continue unless thread.isHidden
|
||||
unless thread.stub
|
||||
nodes[i + 1].hidden = true
|
||||
else unless root.contains thread.stub
|
||||
# When we come back to a page, the stub is already there.
|
||||
ThreadHiding.makeStub thread, root
|
||||
else
|
||||
root.nextElementSibling.hidden = true
|
||||
return
|
||||
|
||||
syncCatalog: ->
|
||||
|
||||
@ -227,6 +227,7 @@ Index =
|
||||
$.nodes Index.nodes
|
||||
Main.callbackNodes Thread, threads
|
||||
Main.callbackNodes Post, posts
|
||||
$.event 'IndexRefresh'
|
||||
buildReplies: (threadRoots) ->
|
||||
posts = []
|
||||
for threadRoot in threadRoots by 2
|
||||
@ -291,5 +292,5 @@ Index =
|
||||
nodes = Index.sortedNodes
|
||||
$.rmAll Index.root
|
||||
Index.buildReplies nodes
|
||||
$.event 'IndexRefresh'
|
||||
$.event 'IndexBuild', nodes
|
||||
$.add Index.root, nodes
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user