Add convenience function QuoteYou.isYou.

This commit is contained in:
ccd0 2017-01-29 18:02:33 -08:00
parent 3b61cbc21f
commit 192eafa670
3 changed files with 12 additions and 13 deletions

View File

@ -112,11 +112,7 @@ Unread =
addPost: ->
return if @isFetchedQuote or @isClone
Unread.order.push @
return if @ID <= Unread.lastReadPost or @isHidden or QuoteYou.db?.get {
boardID: @board.ID
threadID: @thread.ID
postID: @ID
}
return if @ID <= Unread.lastReadPost or @isHidden or QuoteYou.isYou(@)
Unread.posts.add @ID
Unread.addPostQuotingYou @
Unread.position ?= Unread.order[@ID]
@ -172,11 +168,7 @@ Unread =
Unread.posts.delete ID
Unread.postsQuotingYou.delete ID
if QuoteYou.db?.get {
boardID: data.board.ID
threadID: data.thread.ID
postID: ID
}
if QuoteYou.isYou data
QuoteYou.lastRead = root
Unread.position = Unread.position.next

View File

@ -22,7 +22,7 @@ QuoteBacklink =
cb: @secondNode
firstNode: ->
return if @isClone or !@quotes.length or @isRebuilt
markYours = Conf['Mark Quotes of You'] and QuoteYou.db?.get {boardID: @board.ID, threadID: @thread.ID, postID: @ID}
markYours = Conf['Mark Quotes of You'] and QuoteYou.isYou(@)
a = $.el 'a',
href: Build.postURL @board.ID, @thread.ID, @ID
className: if @isHidden then 'filtered backlink' else 'backlink'

View File

@ -31,10 +31,17 @@ QuoteYou =
QuoteYou.menu.init()
isYou: (post) ->
!!QuoteYou.db?.get {
boardID: post.board.ID
threadID: post.thread.ID
postID: post.ID
}
node: ->
return if @isClone
if QuoteYou.db.get {boardID: @board.ID, threadID: @thread.ID, postID: @ID}
if QuoteYou.isYou @
$.addClass @nodes.root, 'yourPost'
# Stop there if there's no quotes in that post.
@ -57,7 +64,7 @@ QuoteYou =
order: 12
open: (post) ->
QuoteYou.menu.post = (post.origin or post)
input.checked = QuoteYou.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID}
input.checked = QuoteYou.isYou post
true
toggle: ->