get quote threading + quote notifications partially working
This commit is contained in:
parent
9668deaa8f
commit
0de728e5a6
@ -6,7 +6,7 @@ Unread =
|
|||||||
@hr = $.el 'hr',
|
@hr = $.el 'hr',
|
||||||
id: 'unread-line'
|
id: 'unread-line'
|
||||||
@posts = new RandomAccessList
|
@posts = new RandomAccessList
|
||||||
@postsQuotingYou = []
|
@postsQuotingYou = {}
|
||||||
|
|
||||||
Thread.callbacks.push
|
Thread.callbacks.push
|
||||||
name: 'Unread'
|
name: 'Unread'
|
||||||
@ -79,21 +79,23 @@ Unread =
|
|||||||
break if ({ID} = post) > Unread.lastReadPost
|
break if ({ID} = post) > Unread.lastReadPost
|
||||||
post = post.next
|
post = post.next
|
||||||
Unread.posts.rm ID
|
Unread.posts.rm ID
|
||||||
|
delete Unread.postsQuotingYou[ID]
|
||||||
|
|
||||||
Unread.readArray Unread.postsQuotingYou
|
|
||||||
Unread.setLine() if Conf['Unread Line']
|
Unread.setLine() if Conf['Unread Line']
|
||||||
Unread.update()
|
Unread.update()
|
||||||
|
|
||||||
|
addPost: (post) ->
|
||||||
|
return if post.ID <= Unread.lastReadPost or post.isHidden or QR.db?.get {
|
||||||
|
boardID: post.board.ID
|
||||||
|
threadID: post.thread.ID
|
||||||
|
postID: post.ID
|
||||||
|
}
|
||||||
|
Unread.posts.push post
|
||||||
|
Unread.addPostQuotingYou post
|
||||||
|
|
||||||
addPosts: (posts) ->
|
addPosts: (posts) ->
|
||||||
for post in posts
|
for post in posts
|
||||||
{ID} = post
|
Unread.addPost post
|
||||||
continue if ID <= Unread.lastReadPost or post.isHidden or QR.db?.get {
|
|
||||||
boardID: post.board.ID
|
|
||||||
threadID: post.thread.ID
|
|
||||||
postID: ID
|
|
||||||
}
|
|
||||||
Unread.posts.push post
|
|
||||||
Unread.addPostQuotingYou post
|
|
||||||
if Conf['Unread Line']
|
if Conf['Unread Line']
|
||||||
# Force line on visible threads if there were no unread posts previously.
|
# Force line on visible threads if there were no unread posts previously.
|
||||||
Unread.setLine Unread.posts.first?.data in posts
|
Unread.setLine Unread.posts.first?.data in posts
|
||||||
@ -102,7 +104,7 @@ Unread =
|
|||||||
|
|
||||||
addPostQuotingYou: (post) ->
|
addPostQuotingYou: (post) ->
|
||||||
for quotelink in post.nodes.quotelinks when QR.db?.get Get.postDataFromLink quotelink
|
for quotelink in post.nodes.quotelinks when QR.db?.get Get.postDataFromLink quotelink
|
||||||
Unread.postsQuotingYou.push post
|
Unread.postsQuotingYou[post.ID] = post
|
||||||
Unread.openNotification post
|
Unread.openNotification post
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -126,7 +128,7 @@ Unread =
|
|||||||
onUpdate: (e) ->
|
onUpdate: (e) ->
|
||||||
if e.detail[404]
|
if e.detail[404]
|
||||||
Unread.update()
|
Unread.update()
|
||||||
else if !Conf['Quote Threading']
|
else if !QuoteThreading.enabled
|
||||||
Unread.addPosts e.detail.newPosts
|
Unread.addPosts e.detail.newPosts
|
||||||
else
|
else
|
||||||
Unread.read()
|
Unread.read()
|
||||||
@ -136,19 +138,13 @@ Unread =
|
|||||||
{ID} = post
|
{ID} = post
|
||||||
{posts} = Unread
|
{posts} = Unread
|
||||||
return unless posts[ID]
|
return unless posts[ID]
|
||||||
if post is posts.first
|
if post is posts.first and !QuoteThreading.enabled
|
||||||
Unread.lastReadPost = ID
|
Unread.lastReadPost = ID
|
||||||
Unread.saveLastReadPost()
|
Unread.saveLastReadPost()
|
||||||
posts.rm ID
|
posts.rm ID
|
||||||
if (i = Unread.postsQuotingYou.indexOf post) isnt -1
|
delete Unread.postsQuotingYou[ID]
|
||||||
Unread.postsQuotingYou.splice i, 1
|
|
||||||
Unread.update()
|
Unread.update()
|
||||||
|
|
||||||
readArray: (arr) ->
|
|
||||||
for post, i in arr
|
|
||||||
break if post.ID > Unread.lastReadPost
|
|
||||||
arr.splice 0, i
|
|
||||||
|
|
||||||
read: $.debounce 100, (e) ->
|
read: $.debounce 100, (e) ->
|
||||||
return if d.hidden or !Unread.posts.length
|
return if d.hidden or !Unread.posts.length
|
||||||
height = doc.clientHeight
|
height = doc.clientHeight
|
||||||
@ -158,6 +154,7 @@ Unread =
|
|||||||
break unless Header.getBottomOf(post.data.nodes.root) > -1 # post is not completely read
|
break unless Header.getBottomOf(post.data.nodes.root) > -1 # post is not completely read
|
||||||
{ID, data} = post
|
{ID, data} = post
|
||||||
posts.rm ID
|
posts.rm ID
|
||||||
|
delete Unread.postsQuotingYou[ID]
|
||||||
|
|
||||||
if Conf['Mark Quotes of You'] and QR.db?.get {
|
if Conf['Mark Quotes of You'] and QR.db?.get {
|
||||||
boardID: data.board.ID
|
boardID: data.board.ID
|
||||||
@ -168,9 +165,9 @@ Unread =
|
|||||||
|
|
||||||
return unless ID
|
return unless ID
|
||||||
|
|
||||||
Unread.lastReadPost = ID if Unread.lastReadPost < ID or !Unread.lastReadPost
|
unless QuoteThreading.enabled
|
||||||
Unread.saveLastReadPost()
|
Unread.lastReadPost = ID if Unread.lastReadPost < ID or !Unread.lastReadPost
|
||||||
Unread.readArray Unread.postsQuotingYou
|
Unread.saveLastReadPost()
|
||||||
Unread.update() if e
|
Unread.update() if e
|
||||||
|
|
||||||
saveLastReadPost: $.debounce 2 * $.SECOND, ->
|
saveLastReadPost: $.debounce 2 * $.SECOND, ->
|
||||||
@ -188,15 +185,16 @@ Unread =
|
|||||||
|
|
||||||
update: ->
|
update: ->
|
||||||
count = Unread.posts.length
|
count = Unread.posts.length
|
||||||
|
countQuotingYou = Object.keys(Unread.postsQuotingYou).length
|
||||||
|
|
||||||
if Conf['Unread Count']
|
if Conf['Unread Count']
|
||||||
d.title = "#{if Conf['Quoted Title'] and Unread.postsQuotingYou.length then '(!) ' else ''}#{if count or !Conf['Hide Unread Count at (0)'] then "(#{count}) " else ''}#{if g.DEAD then "/#{g.BOARD}/ - 404" else "#{Unread.title}"}"
|
d.title = "#{if Conf['Quoted Title'] and countQuotingYou then '(!) ' else ''}#{if count or !Conf['Hide Unread Count at (0)'] then "(#{count}) " else ''}#{if g.DEAD then "/#{g.BOARD}/ - 404" else "#{Unread.title}"}"
|
||||||
|
|
||||||
return unless Conf['Unread Favicon']
|
return unless Conf['Unread Favicon']
|
||||||
|
|
||||||
Favicon.el.href =
|
Favicon.el.href =
|
||||||
if g.DEAD
|
if g.DEAD
|
||||||
if Unread.postsQuotingYou[0]
|
if countQuotingYou
|
||||||
Favicon.unreadDeadY
|
Favicon.unreadDeadY
|
||||||
else if count
|
else if count
|
||||||
Favicon.unreadDead
|
Favicon.unreadDead
|
||||||
@ -204,7 +202,7 @@ Unread =
|
|||||||
Favicon.dead
|
Favicon.dead
|
||||||
else
|
else
|
||||||
if count
|
if count
|
||||||
if Unread.postsQuotingYou[0]
|
if countQuotingYou
|
||||||
Favicon.unreadY
|
Favicon.unreadY
|
||||||
else
|
else
|
||||||
Favicon.unread
|
Favicon.unread
|
||||||
|
|||||||
@ -53,7 +53,7 @@ QuoteThreading =
|
|||||||
{posts} = g
|
{posts} = g
|
||||||
return if @isClone or not QuoteThreading.enabled
|
return if @isClone or not QuoteThreading.enabled
|
||||||
|
|
||||||
Unread.posts.push @ if Conf['Unread Count']
|
Unread.addPost @ if Conf['Unread Count']
|
||||||
return if @thread.OP is @ or @isHidden # Filtered
|
return if @thread.OP is @ or @isHidden # Filtered
|
||||||
|
|
||||||
keys = []
|
keys = []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user