From bddb032dac47663cfd7a759aac8b8ca7d810f028 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 3 Nov 2013 16:47:22 +0100 Subject: [PATCH] We only have to look for one thread when visiting thread pages. --- src/General/Index.coffee | 3 +-- src/General/Main.coffee | 31 +++++++++++++------------------ 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/General/Index.coffee b/src/General/Index.coffee index c9a8b5134..5946e0e5f 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -202,8 +202,7 @@ Index = posts.push new Post postRoot, thread, g.BOARD catch err # Skip posts that we failed to parse. - unless errors - errors = [] + errors = [] unless errors errors.push message: "Parsing of Post No.#{postRoot.id.match /\d+/} failed. Post will be skipped." error: err diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 9756b15e2..e0b9abc8b 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -169,26 +169,21 @@ Main = # Something might have gone wrong! Main.initStyle() - if g.VIEW is 'thread' and board = $ '.board' - threads = [] - posts = [] - - for threadRoot in $$ '.board > .thread', board - thread = new Thread +threadRoot.id[1..], g.BOARD - threads.push thread - for postRoot in $$ '.thread > .postContainer', threadRoot - try - posts.push new Post postRoot, thread, g.BOARD - catch err - # Skip posts that we failed to parse. - unless errors - errors = [] - errors.push - message: "Parsing of Post No.#{postRoot.id.match /\d+/} failed. Post will be skipped." - error: err + if g.VIEW is 'thread' and threadRoot = $ '.thread' + thread = new Thread +threadRoot.id[1..], g.BOARD + posts = [] + for postRoot in $$ '.thread > .postContainer', threadRoot + try + posts.push new Post postRoot, thread, g.BOARD + catch err + # Skip posts that we failed to parse. + errors = [] unless errors + errors.push + message: "Parsing of Post No.#{postRoot.id.match /\d+/} failed. Post will be skipped." + error: err Main.handleErrors errors if errors - Main.callbackNodes Thread, threads + Main.callbackNodes Thread, [thread] Main.callbackNodes Post, posts if $.hasClass d.body, 'fourchan_x'