Implement thread.lastPost.

This commit is contained in:
ccd0 2019-07-13 03:14:03 -07:00
parent 71187133c1
commit 393ee447d7
4 changed files with 7 additions and 11 deletions

View File

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

View File

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

View File

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

View File

@ -11,6 +11,7 @@ class Thread
@isArchived = false
@postLimit = false
@fileLimit = false
@lastPost = 0
@ipCount = undefined
@json = null