rewrite Unread.setLine
This commit is contained in:
parent
e53cbc335f
commit
6e0772ed5d
@ -44,10 +44,9 @@ Unread =
|
|||||||
# Let the header's onload callback handle it.
|
# Let the header's onload callback handle it.
|
||||||
return if (hash = location.hash.match /\d+/) and hash[0] of Unread.thread.posts
|
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
|
{posts} = Unread.thread
|
||||||
for ID in posts.keys by -1
|
for ID in posts.keys by -1 when +ID <= Unread.lastReadPost
|
||||||
continue if +ID > Unread.lastReadPost
|
|
||||||
{root} = posts[ID].nodes
|
{root} = posts[ID].nodes
|
||||||
if root.getBoundingClientRect().height
|
if root.getBoundingClientRect().height
|
||||||
Header.scrollToIfNeeded root, true
|
Header.scrollToIfNeeded root, true
|
||||||
@ -167,9 +166,11 @@ Unread =
|
|||||||
|
|
||||||
setLine: (force) ->
|
setLine: (force) ->
|
||||||
return unless d.hidden or force is true
|
return unless d.hidden or force is true
|
||||||
return $.rm Unread.hr unless post = Unread.posts.first
|
return $.rm Unread.hr unless Unread.posts.length
|
||||||
if $.x 'preceding-sibling::div[contains(@class,"replyContainer")]', post.data.nodes.root # not the first reply
|
{posts} = Unread.thread
|
||||||
$.before post.data.nodes.root, Unread.hr
|
for ID in posts.keys by -1 when +ID <= Unread.lastReadPost
|
||||||
|
return $.after posts[ID].nodes.root, Unread.hr
|
||||||
|
return
|
||||||
|
|
||||||
update: ->
|
update: ->
|
||||||
count = Unread.posts.length
|
count = Unread.posts.length
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user