From a502db7f47d6f301a02b9865cf07a7854ce319e9 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 23 Nov 2014 13:02:38 -0800 Subject: [PATCH] More quote threading compatible lastReadPost computation. --- src/Monitoring/Unread.coffee | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index ff42dfcf5..96f198af0 100755 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -120,11 +120,9 @@ Unread = {ID} = post {posts} = Unread return unless posts[ID] - if post is posts.first and !(Conf['Quote Threading'] and Unread.posts.length) - Unread.lastReadPost = ID - Unread.saveLastReadPost() posts.rm ID delete Unread.postsQuotingYou[ID] + Unread.saveLastReadPost() Unread.update() read: $.debounce 100, (e) -> @@ -132,11 +130,11 @@ Unread = height = doc.clientHeight {posts} = Unread - maxID = 0 + count = 0 while post = posts.first break unless Header.getBottomOf(post.data.nodes.root) > -1 # post is not completely read {ID, data} = post - maxID = Math.max maxID, ID + count++ posts.rm ID delete Unread.postsQuotingYou[ID] @@ -147,15 +145,16 @@ Unread = } QuoteYou.lastRead = data.nodes.root - return unless maxID - - unless Conf['Quote Threading'] and posts.length - Unread.lastReadPost = maxID if Unread.lastReadPost < maxID or !Unread.lastReadPost - Unread.saveLastReadPost() + return unless count + Unread.saveLastReadPost() Unread.update() if e saveLastReadPost: $.debounce 2 * $.SECOND, -> + for ID in Unread.thread.posts.keys + break if Unread.posts[ID] + Unread.lastReadPost = +ID if +ID > Unread.lastReadPost return if Unread.thread.isDead and !Unread.thread.isArchived + Unread.db.forceSync() Unread.db.set boardID: Unread.thread.board.ID threadID: Unread.thread.ID