Implement thread.lastPost.
This commit is contained in:
parent
71187133c1
commit
393ee447d7
@ -687,10 +687,6 @@ Index =
|
|||||||
isHiddenReply: (threadID, replyData) ->
|
isHiddenReply: (threadID, replyData) ->
|
||||||
PostHiding.isHidden(g.BOARD.ID, threadID, replyData.no) or Filter.isHidden(g.SITE.Build.parseJSON replyData, g.BOARD.ID)
|
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) ->
|
buildThreads: (threadIDs, isCatalog, withReplies) ->
|
||||||
threads = []
|
threads = []
|
||||||
newThreads = []
|
newThreads = []
|
||||||
@ -712,6 +708,8 @@ Index =
|
|||||||
else
|
else
|
||||||
thread = new Thread ID, g.BOARD
|
thread = new Thread ID, g.BOARD
|
||||||
newThreads.push thread
|
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
|
thread.json = threadData
|
||||||
threads.push thread
|
threads.push thread
|
||||||
|
|
||||||
|
|||||||
@ -75,7 +75,7 @@ UnreadIndex =
|
|||||||
hasUnread = if repliesShown
|
hasUnread = if repliesShown
|
||||||
firstUnread or !repliesRead
|
firstUnread or !repliesRead
|
||||||
else if Index.enabled
|
else if Index.enabled
|
||||||
Index.lastPost(thread.ID) > lastReadPost
|
thread.lastPost > lastReadPost
|
||||||
else
|
else
|
||||||
thread.OP.ID > lastReadPost
|
thread.OP.ID > lastReadPost
|
||||||
thread.nodes.root.classList.toggle 'unread-thread', hasUnread
|
thread.nodes.root.classList.toggle 'unread-thread', hasUnread
|
||||||
@ -94,15 +94,11 @@ UnreadIndex =
|
|||||||
|
|
||||||
markRead: ->
|
markRead: ->
|
||||||
thread = Get.threadFromNode @
|
thread = Get.threadFromNode @
|
||||||
lastPost = if Index.enabled then Index.lastPost(thread.ID) else 0
|
UnreadIndex.lastReadPost[thread.fullID] = thread.lastPost
|
||||||
thread.posts.forEach (post) ->
|
|
||||||
if post.ID > lastPost and !post.isFetchedQuote
|
|
||||||
lastPost = post.ID
|
|
||||||
UnreadIndex.lastReadPost[thread.fullID] = lastPost
|
|
||||||
UnreadIndex.db.set
|
UnreadIndex.db.set
|
||||||
boardID: thread.board.ID
|
boardID: thread.board.ID
|
||||||
threadID: thread.ID
|
threadID: thread.ID
|
||||||
val: lastPost
|
val: thread.lastPost
|
||||||
$.rm UnreadIndex.hr[thread.fullID]
|
$.rm UnreadIndex.hr[thread.fullID]
|
||||||
thread.nodes.root.classList.remove 'unread-thread'
|
thread.nodes.root.classList.remove 'unread-thread'
|
||||||
ThreadWatcher.update g.SITE.ID, thread.board.ID, thread.ID,
|
ThreadWatcher.update g.SITE.ID, thread.board.ID, thread.ID,
|
||||||
|
|||||||
@ -63,6 +63,7 @@ class Post
|
|||||||
@clones = g.posts[@fullID].clones
|
@clones = g.posts[@fullID].clones
|
||||||
clone.origin = @ for clone in @clones
|
clone.origin = @ for clone in @clones
|
||||||
|
|
||||||
|
@thread.lastPost = @ID if !@isFetchedQuote and @ID > @thread.lastPost
|
||||||
@board.posts.push @ID, @
|
@board.posts.push @ID, @
|
||||||
@thread.posts.push @ID, @
|
@thread.posts.push @ID, @
|
||||||
g.posts.push @fullID, @
|
g.posts.push @fullID, @
|
||||||
|
|||||||
@ -11,6 +11,7 @@ class Thread
|
|||||||
@isArchived = false
|
@isArchived = false
|
||||||
@postLimit = false
|
@postLimit = false
|
||||||
@fileLimit = false
|
@fileLimit = false
|
||||||
|
@lastPost = 0
|
||||||
@ipCount = undefined
|
@ipCount = undefined
|
||||||
@json = null
|
@json = null
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user