diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 921d31c1d..c67022a5c 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -687,10 +687,6 @@ Index = isHiddenReply: (threadID, replyData) -> PostHiding.isHidden(g.BOARD.ID, threadID, replyData.no) or Filter.isHidden(g.SITE.Build.parseJSON replyData, g.BOARD.ID) - lastPost: (threadID) -> - threadData = Index.liveThreadDict[threadID] - if threadData?.last_replies then threadData.last_replies[threadData.last_replies.length - 1].no else threadID - buildThreads: (threadIDs, isCatalog, withReplies) -> threads = [] newThreads = [] @@ -712,6 +708,8 @@ Index = else thread = new Thread ID, g.BOARD newThreads.push thread + lastPost = if threadData.last_replies then threadData.last_replies[threadData.last_replies.length - 1].no else ID + thread.lastPost = lastPost if lastPost > thread.lastPost thread.json = threadData threads.push thread diff --git a/src/Monitoring/UnreadIndex.coffee b/src/Monitoring/UnreadIndex.coffee index 1ca6c489c..f7d8afc04 100644 --- a/src/Monitoring/UnreadIndex.coffee +++ b/src/Monitoring/UnreadIndex.coffee @@ -75,7 +75,7 @@ UnreadIndex = hasUnread = if repliesShown firstUnread or !repliesRead else if Index.enabled - Index.lastPost(thread.ID) > lastReadPost + thread.lastPost > lastReadPost else thread.OP.ID > lastReadPost thread.nodes.root.classList.toggle 'unread-thread', hasUnread @@ -94,15 +94,11 @@ UnreadIndex = markRead: -> thread = Get.threadFromNode @ - lastPost = if Index.enabled then Index.lastPost(thread.ID) else 0 - thread.posts.forEach (post) -> - if post.ID > lastPost and !post.isFetchedQuote - lastPost = post.ID - UnreadIndex.lastReadPost[thread.fullID] = lastPost + UnreadIndex.lastReadPost[thread.fullID] = thread.lastPost UnreadIndex.db.set boardID: thread.board.ID threadID: thread.ID - val: lastPost + val: thread.lastPost $.rm UnreadIndex.hr[thread.fullID] thread.nodes.root.classList.remove 'unread-thread' ThreadWatcher.update g.SITE.ID, thread.board.ID, thread.ID, diff --git a/src/classes/Post.coffee b/src/classes/Post.coffee index c76a2500b..dfe523db7 100644 --- a/src/classes/Post.coffee +++ b/src/classes/Post.coffee @@ -63,6 +63,7 @@ class Post @clones = g.posts[@fullID].clones clone.origin = @ for clone in @clones + @thread.lastPost = @ID if !@isFetchedQuote and @ID > @thread.lastPost @board.posts.push @ID, @ @thread.posts.push @ID, @ g.posts.push @fullID, @ diff --git a/src/classes/Thread.coffee b/src/classes/Thread.coffee index 25f97d0dc..6bfbbd039 100644 --- a/src/classes/Thread.coffee +++ b/src/classes/Thread.coffee @@ -11,6 +11,7 @@ class Thread @isArchived = false @postLimit = false @fileLimit = false + @lastPost = 0 @ipCount = undefined @json = null