Fix race condition between clearing index and inserting rest of catalog.

This commit is contained in:
ccd0 2016-10-03 00:19:39 -07:00
parent 8115d7d136
commit 28e2ea7af7

View File

@ -807,9 +807,11 @@ Index =
buildCatalog: (threadIDs) -> buildCatalog: (threadIDs) ->
i = 0 i = 0
n = threadIDs.length n = threadIDs.length
node0 = null
fn = -> fn = ->
return if node0 and !node0.parentNode # Index.root cleared
j = if i > 0 and Index.root.parentNode then n else i + 30 j = if i > 0 and Index.root.parentNode then n else i + 30
Index.buildCatalogPart threadIDs[i...j] node0 = Index.buildCatalogPart(threadIDs[i...j])[0]
i = j i = j
if i < n if i < n
$.queueTask fn $.queueTask fn
@ -831,7 +833,7 @@ Index =
$.add thread.catalogView.nodes.root, thread.OP.nodes.root $.add thread.catalogView.nodes.root, thread.OP.nodes.root
nodes.push thread.catalogView.nodes.root nodes.push thread.catalogView.nodes.root
$.add Index.root, nodes $.add Index.root, nodes
return nodes
clearSearch: -> clearSearch: ->
Index.searchInput.value = '' Index.searchInput.value = ''