From 6e0772ed5d0b63ac126b7aa601a58061f43c2c85 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 22 Nov 2014 22:51:52 -0800 Subject: [PATCH] rewrite Unread.setLine --- src/Monitoring/Unread.coffee | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index 2ccd761d9..5793002a5 100755 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -44,10 +44,9 @@ Unread = # Let the header's onload callback handle it. return if (hash = location.hash.match /\d+/) and hash[0] of Unread.thread.posts - # Scroll to the last non-hidden non-deleted read post. + # Scroll to the last displayed non-deleted read post. {posts} = Unread.thread - for ID in posts.keys by -1 - continue if +ID > Unread.lastReadPost + for ID in posts.keys by -1 when +ID <= Unread.lastReadPost {root} = posts[ID].nodes if root.getBoundingClientRect().height Header.scrollToIfNeeded root, true @@ -167,9 +166,11 @@ Unread = setLine: (force) -> return unless d.hidden or force is true - return $.rm Unread.hr unless post = Unread.posts.first - if $.x 'preceding-sibling::div[contains(@class,"replyContainer")]', post.data.nodes.root # not the first reply - $.before post.data.nodes.root, Unread.hr + return $.rm Unread.hr unless Unread.posts.length + {posts} = Unread.thread + for ID in posts.keys by -1 when +ID <= Unread.lastReadPost + return $.after posts[ID].nodes.root, Unread.hr + return update: -> count = Unread.posts.length