diff --git a/src/Filtering/ThreadHiding.coffee b/src/Filtering/ThreadHiding.coffee index 55fd4dd77..80c11b1d2 100644 --- a/src/Filtering/ThreadHiding.coffee +++ b/src/Filtering/ThreadHiding.coffee @@ -16,8 +16,12 @@ ThreadHiding = $.prepend @OP.nodes.root, ThreadHiding.makeButton @, 'hide' onrefresh: -> - for threadID, thread of g.BOARD.threads when thread.isHidden and thread.stub - $.prepend thread.OP.nodes.root.parentNode, thread.stub + for threadID, thread of g.BOARD.threads when thread.isHidden + root = thread.OP.nodes.root.parentNode + if thread.stub + $.prepend root, thread.stub + else + threadRoot.nextElementSibling.hidden = true return syncCatalog: -> diff --git a/src/General/Build.coffee b/src/General/Build.coffee index 74b40338b..c621afa3c 100644 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -271,26 +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 + if (OP = board.posts[data.no]) and root = OP.nodes.root.parentNode $.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] - post.nodes.root - else - Build.postFromObject obj, board.ID - - # build if necessary + nodes = [if OP then OP.nodes.root else Build.postFromObject data, board.ID] if data.omitted_posts - nodes.splice 1, 0, Build.summary board.ID, data.no, data.omitted_posts, data.omitted_images + nodes.push Build.summary board.ID, data.no, data.omitted_posts, data.omitted_images $.add root, nodes - [root, hr] + root diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 5f66c0f40..5e0713f62 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -158,6 +158,7 @@ Index = try Index.parse JSON.parse req.response if req.status is 200 catch err + c.error 'Index failure:', err.stack # network error or non-JSON content for example. notice.setType 'error' notice.el.lastElementChild.textContent = 'Index refresh failed.' @@ -171,7 +172,7 @@ Index = Index.scrollToIndex() parse: (pages) -> Index.parseThreadList pages - Index.buildAll() + Index.buildThreads() Index.sort() Index.buildIndex() Index.buildPagelist() @@ -183,35 +184,59 @@ Index = for threadID, thread of g.BOARD.threads when thread.ID not in Index.liveThreadIDs thread.collect() return - buildAll: -> + buildThreads: -> Index.nodes = [] threads = [] posts = [] for threadData in Index.liveThreadData - [threadRoot, hr] = Build.thread g.BOARD, threadData - Index.nodes.push threadRoot, hr + threadRoot = Build.thread g.BOARD, threadData + Index.nodes.push threadRoot, $.el 'hr' if thread = g.BOARD.threads[threadData.no] thread.setStatus 'Sticky', !!threadData.sticky thread.setStatus 'Closed', !!threadData.closed else thread = new Thread threadData.no, g.BOARD threads.push thread - postRoots = $$ '.thread > .postContainer', threadRoot - for postRoot in postRoots when postRoot.id.match(/\d+/)[0] not of thread.posts + # postRoots = $$ '.thread > .postContainer', threadRoot + # for postRoot in postRoots when postRoot.id.match(/\d+/)[0] not of thread.posts + OPRoot = $ '.opContainer', threadRoot + continue if OPRoot.id.match(/\d+/)[0] of thread.posts + try + posts.push new Post OPRoot, thread, g.BOARD + catch err + # Skip posts that we failed to parse. + Main.handleErrors + message: "Parsing of Post No.#{postRoot.id.match /\d+/} failed. Post will be skipped." + error: err + + # Add the threads and