Better thread data lookup.

This commit is contained in:
ccd0 2016-09-25 03:48:25 -07:00
parent 84b7f546a5
commit 3a568ab366
2 changed files with 5 additions and 3 deletions

View File

@ -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"

View File

@ -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