Avoid creating new thread root+<hr> when they already exist.
This commit is contained in:
parent
aeea95564c
commit
bc0f5fcc3b
@ -16,10 +16,8 @@ ThreadHiding =
|
||||
$.prepend @OP.nodes.root, ThreadHiding.makeButton @, 'hide'
|
||||
|
||||
onrefresh: ->
|
||||
for threadID, thread of g.BOARD.threads when thread.isHidden
|
||||
hasStub = !!thread.stub
|
||||
ThreadHiding.show thread
|
||||
ThreadHiding.hide thread, hasStub
|
||||
for threadID, thread of g.BOARD.threads when thread.isHidden and thread.stub
|
||||
$.prepend thread.OP.nodes.root.parentNode, thread.stub
|
||||
return
|
||||
|
||||
syncCatalog: ->
|
||||
|
||||
@ -271,6 +271,16 @@ Build =
|
||||
thread: (board, data) ->
|
||||
Build.spoilerRange[board] = data.custom_spoiler
|
||||
|
||||
if (OP = board.posts[data.no]) and parent = OP.nodes.root.parentNode
|
||||
root = parent
|
||||
hr = parent.nextElementSibling
|
||||
$.rmAll root
|
||||
else
|
||||
root = $.el 'div',
|
||||
className: 'thread'
|
||||
id: "t#{data.no}"
|
||||
hr = $.el 'hr'
|
||||
|
||||
nodes = []
|
||||
for obj in [data].concat data.last_replies or []
|
||||
nodes.push if post = board.posts[obj.no]
|
||||
@ -282,8 +292,5 @@ Build =
|
||||
if data.omitted_posts
|
||||
nodes.splice 1, 0, Build.summary board.ID, data.no, data.omitted_posts, data.omitted_images
|
||||
|
||||
root = $.el 'div',
|
||||
className: 'thread'
|
||||
id: "t#{data.no}"
|
||||
$.add root, nodes
|
||||
root
|
||||
[root, hr]
|
||||
|
||||
@ -188,8 +188,8 @@ Index =
|
||||
threads = []
|
||||
posts = []
|
||||
for threadData in Index.liveThreadData
|
||||
threadRoot = Build.thread g.BOARD, threadData
|
||||
Index.nodes.push threadRoot, $.el 'hr'
|
||||
[threadRoot, hr] = Build.thread g.BOARD, threadData
|
||||
Index.nodes.push threadRoot, hr
|
||||
if thread = g.BOARD.threads[threadData.no]
|
||||
thread.setStatus 'Sticky', !!threadData.sticky
|
||||
thread.setStatus 'Closed', !!threadData.closed
|
||||
@ -250,6 +250,6 @@ Index =
|
||||
nodes = Index.sortedNodes[nodesPerPage * pageNum ... nodesPerPage * (pageNum + 1)]
|
||||
else
|
||||
nodes = Index.sortedNodes
|
||||
$.event 'IndexRefresh'
|
||||
$.rmAll Index.root
|
||||
$.event 'IndexRefresh'
|
||||
$.add Index.root, nodes
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user