Find posts quoting you, change tab icon if there are unread posts quoting you. #916

This commit is contained in:
Nicolas Stepien 2013-02-23 21:16:32 +01:00
parent e7164099c9
commit 16bcac2a57
4 changed files with 71 additions and 17 deletions

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,7 @@ beta
Can be auto-hidden. Can be auto-hidden.
Egocentrism: Egocentrism:
"(You)" will be added to quotes linking to your posts. "(You)" will be added to quotes linking to your posts.
The Unread tab icon will indicate new unread posts quoting you.
Delete links in the post menu will only appear for your posts. Delete links in the post menu will only appear for your posts.
QR changes: QR changes:

View File

@ -344,7 +344,7 @@ a[href="javascript:;"] {
.deadlink { .deadlink {
text-decoration: none !important; text-decoration: none !important;
} }
.backlink.deadlink, .quotelink.deadlink { .backlink.deadlink:not(.forwardlink), .quotelink.deadlink:not(.forwardlink) {
text-decoration: underline !important; text-decoration: underline !important;
} }
.inlined { .inlined {

View File

@ -3308,10 +3308,11 @@ Unread =
cb: @node cb: @node
node: -> node: ->
Unread.thread = @ Unread.thread = @
Unread.lastReadPost = $.get("lastReadPosts.#{@board}", threads: {}).threads[@] or 0 Unread.lastReadPost = $.get("lastReadPosts.#{@board}", threads: {}).threads[@] or 0
Unread.posts = [] Unread.posts = []
Unread.title = d.title Unread.postsQuotingYou = []
Unread.title = d.title
posts = [] posts = []
for ID, post of @posts for ID, post of @posts
posts.push post if post.isReply posts.push post if post.isReply
@ -3321,14 +3322,26 @@ Unread =
addPosts: (newPosts) -> addPosts: (newPosts) ->
if Conf['Quick Reply'] if Conf['Quick Reply']
yourPosts = QR.yourPosts.threads[Unread.thread] {yourPosts} = QR
youInThisThread = yourPosts.threads[Unread.thread]
for post in newPosts for post in newPosts
{ID} = post {ID} = post
unless ID <= Unread.lastReadPost or post.isHidden or yourPosts and ID in yourPosts if ID <= Unread.lastReadPost or post.isHidden or youInThisThread and ID in youInThisThread
Unread.posts.push post continue
Unread.posts.push post
Unread.addPostQuotingYou post, yourPosts if yourPosts
Unread.read() Unread.read()
Unread.update() Unread.update()
addPostQuotingYou: (post, yourPosts) ->
for quote in post.quotes
[board, quoteID] = quote.split '.'
continue unless board is Unread.thread.board.ID
for thread, postIDs of yourPosts.threads
if +quoteID in postIDs
Unread.postsQuotingYou.push post
return
onUpdate: (e) -> onUpdate: (e) ->
if e.detail[404] if e.detail[404]
Unread.update() Unread.update()
@ -3346,6 +3359,9 @@ Unread =
Unread.lastReadPost = Unread.posts[i - 1].ID Unread.lastReadPost = Unread.posts[i - 1].ID
Unread.saveLastReadPost() Unread.saveLastReadPost()
Unread.posts = Unread.posts[i..] Unread.posts = Unread.posts[i..]
for post, i in Unread.postsQuotingYou
break if post.ID > Unread.lastReadPost
Unread.postsQuotingYou = Unread.postsQuotingYou[i..]
Unread.update() if e Unread.update() if e
saveLastReadPost: $.debounce($.SECOND, -> saveLastReadPost: $.debounce($.SECOND, ->
@ -3367,12 +3383,16 @@ Unread =
Favicon.el.href = Favicon.el.href =
if g.DEAD if g.DEAD
if count if Unread.postsQuotingYou.length
'//static.4chan.org/image/favicon-status.ico' # XXX
else if count
Favicon.unreadDead Favicon.unreadDead
else else
Favicon.dead Favicon.dead
else else
if count if Unread.postsQuotingYou.length
'//static.4chan.org/image/favicon-status.ico' # XXX
else if count
Favicon.unread Favicon.unread
else else
Favicon.default Favicon.default