From 3a568ab366297f8d759d09acb25a77b44893a3c9 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 25 Sep 2016 03:48:25 -0700 Subject: [PATCH] Better thread data lookup. --- src/General/Build.coffee | 2 +- src/General/Index.coffee | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/General/Build.coffee b/src/General/Build.coffee index a92fbe0a7..1d22c6696 100644 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -183,7 +183,7 @@ Build = catalogThread: (thread) -> {staticPath, gifIcon} = Build - data = Index.liveThreadData[Index.liveThreadIDs.indexOf thread.ID] + data = Index.liveThreadDict[thread.ID] if data.spoiler and !Conf['Reveal Spoiler Thumbnails'] src = "#{staticPath}spoiler" diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 8d6aba467..fe8e1158e 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -562,6 +562,9 @@ Index = Index.threadsNumPerPage = pages[0]?.threads.length or 1 Index.liveThreadData = pages.reduce ((arr, next) -> arr.concat next.threads), [] Index.liveThreadIDs = Index.liveThreadData.map (data) -> data.no + Index.liveThreadDict = {} + for data in Index.liveThreadData + Index.liveThreadDict[data.no] = data if Index.liveThreadData[0] Build.spoilerRange[g.BOARD.ID] = Index.liveThreadData[0].custom_spoiler g.BOARD.threads.forEach (thread) -> @@ -606,8 +609,7 @@ Index = buildReplies: (threads) -> posts = [] for thread in threads - i = Index.liveThreadIDs.indexOf thread.ID - continue unless lastReplies = Index.liveThreadData[i].last_replies + continue unless lastReplies = Index.liveThreadDict[thread.ID].last_replies nodes = [] for data in lastReplies if (post = thread.posts[data.no]) and not post.isFetchedQuote