Implement thread.lastPost.
This commit is contained in:
parent
71187133c1
commit
393ee447d7
@ -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
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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, @
|
||||
|
||||
@ -11,6 +11,7 @@ class Thread
|
||||
@isArchived = false
|
||||
@postLimit = false
|
||||
@fileLimit = false
|
||||
@lastPost = 0
|
||||
@ipCount = undefined
|
||||
@json = null
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user