Fix unread count not taking into account hidden posts on page load.
Fix unread freezing on page load.
This commit is contained in:
parent
3244c0f696
commit
f2a9ba5a0c
@ -1,3 +1,5 @@
|
|||||||
|
- Fix bug where a thread would freeze on load.
|
||||||
|
|
||||||
### 3.2.1 - *2013-04-26*
|
### 3.2.1 - *2013-04-26*
|
||||||
|
|
||||||
- Minor fixes.
|
- Minor fixes.
|
||||||
|
|||||||
@ -15,26 +15,34 @@ Unread =
|
|||||||
node: ->
|
node: ->
|
||||||
Unread.thread = @
|
Unread.thread = @
|
||||||
Unread.title = d.title
|
Unread.title = d.title
|
||||||
posts = []
|
|
||||||
for ID, post of @posts
|
|
||||||
posts.push post if post.isReply
|
|
||||||
Unread.lastReadPost = Unread.db.get
|
Unread.lastReadPost = Unread.db.get
|
||||||
boardID: @board.ID
|
boardID: @board.ID
|
||||||
threadID: @ID
|
threadID: @ID
|
||||||
defaultValue: 0
|
defaultValue: 0
|
||||||
Unread.addPosts posts
|
$.on d, '4chanXInitFinished', Unread.ready
|
||||||
$.on d, 'ThreadUpdate', Unread.onUpdate
|
$.on d, 'ThreadUpdate', Unread.onUpdate
|
||||||
$.on d, 'scroll visibilitychange', Unread.read
|
$.on d, 'scroll visibilitychange', Unread.read
|
||||||
$.on d, 'visibilitychange', Unread.setLine if Conf['Unread Line']
|
$.on d, 'visibilitychange', Unread.setLine if Conf['Unread Line']
|
||||||
$.on window, 'load', Unread.scroll if Conf['Scroll to Last Read Post']
|
$.on window, 'load', Unread.scroll if Conf['Scroll to Last Read Post']
|
||||||
|
|
||||||
|
ready: ->
|
||||||
|
$.off d, '4chanXInitFinished', Unread.ready
|
||||||
|
posts = []
|
||||||
|
for ID, post of Unread.thread.posts
|
||||||
|
posts.push post if post.isReply
|
||||||
|
Unread.addPosts posts
|
||||||
|
|
||||||
scroll: ->
|
scroll: ->
|
||||||
# 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
|
||||||
if Unread.posts.length
|
if Unread.posts.length
|
||||||
# Scroll to before the first unread post.
|
# Scroll to before the first unread post.
|
||||||
|
prevID = 0
|
||||||
while root = $.x 'preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root
|
while root = $.x 'preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root
|
||||||
break unless (Get.postFromRoot root).isHidden
|
post = Get.postFromRoot root
|
||||||
|
break if prevID is post.ID
|
||||||
|
prevID = post.ID
|
||||||
|
break unless post.isHidden
|
||||||
root.scrollIntoView false
|
root.scrollIntoView false
|
||||||
return
|
return
|
||||||
# Scroll to the last read post.
|
# Scroll to the last read post.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user