Remove dependence of 'Remember Your Posts' suboptions on 'Quick Reply'. #677

This commit is contained in:
ccd0 2016-01-28 19:45:04 -08:00
parent b2db2dc224
commit a22ca7a3f3
6 changed files with 21 additions and 25 deletions

View File

@ -184,10 +184,10 @@ Keybinds =
return unless thread
ThreadHiding.toggle thread if ThreadHiding.db
when Conf['Previous Post Quoting You']
return unless threadRoot and QR.db
return unless threadRoot and QuoteYou.db
QuoteYou.cb.seek 'preceding'
when Conf['Next Post Quoting You']
return unless threadRoot and QR.db
return unless threadRoot and QuoteYou.db
QuoteYou.cb.seek 'following'
<% if (tests_enabled) { %>
when 't'

View File

@ -192,7 +192,7 @@ ThreadWatcher =
fetchAllStatus: ->
ThreadWatcher.db.forceSync()
ThreadWatcher.unreaddb.forceSync()
QR.db?.forceSync()
QuoteYou.db?.forceSync()
return unless (threads = ThreadWatcher.getAll()).length
for thread in threads
ThreadWatcher.fetchStatus thread
@ -235,16 +235,16 @@ ThreadWatcher =
for postObj in @response.posts
continue unless postObj.no > lastReadPost
continue if QR.db?.get {boardID, threadID, postID: postObj.no}
continue if QuoteYou.db?.get {boardID, threadID, postID: postObj.no}
unread++
continue unless QR.db and postObj.com
continue unless QuoteYou.db and postObj.com
quotesYou = false
regexp = /<a [^>]*\bhref="(?:\/([^\/]+)\/thread\/)?(\d+)?(?:#p(\d+))?"/g
while match = regexp.exec postObj.com
if QR.db.get {
if QuoteYou.db.get {
boardID: match[1] or boardID
threadID: match[2] or threadID
postID: match[3] or match[2] or threadID

View File

@ -112,7 +112,7 @@ Unread =
addPost: ->
return if @isFetchedQuote or @isClone
Unread.order.push @
return if @ID <= Unread.lastReadPost or @isHidden or QR.db?.get {
return if @ID <= Unread.lastReadPost or @isHidden or QuoteYou.db?.get {
boardID: @board.ID
threadID: @thread.ID
postID: @ID
@ -122,7 +122,7 @@ Unread =
Unread.position ?= Unread.order[@ID]
addPostQuotingYou: (post) ->
for quotelink in post.nodes.quotelinks when QR.db?.get Get.postDataFromLink quotelink
for quotelink in post.nodes.quotelinks when QuoteYou.db?.get Get.postDataFromLink quotelink
Unread.postsQuotingYou.add post.ID
Unread.openNotification post
return
@ -176,7 +176,7 @@ Unread =
Unread.posts.delete ID
Unread.postsQuotingYou.delete ID
if QR.db?.get {
if QuoteYou.db?.get {
boardID: data.board.ID
threadID: data.thread.ID
postID: ID

View File

@ -24,10 +24,6 @@ QR =
init: ->
return unless Conf['Quick Reply']
if Conf['Remember Your Posts']
$.sync 'Remember Your Posts', (enabled) -> Conf['Remember Your Posts'] = enabled
@db = new DataBoard 'yourPosts'
@posts = []
return if g.VIEW is 'archive'
@ -769,14 +765,6 @@ QR =
threadID = +threadID or postID
isReply = threadID isnt postID
$.forceSync 'Remember Your Posts'
if Conf['Remember Your Posts']
QR.db?.set
boardID: g.BOARD.ID
threadID: threadID
postID: postID
val: true
# Post/upload confirmed as successful.
$.event 'QRPostSuccessful', {
boardID: g.BOARD.ID

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 QR.db?.get {boardID: @board.ID, threadID: @thread.ID, postID: @ID}
markYours = Conf['Mark Quotes of You'] and QuoteYou.db?.get {boardID: @board.ID, threadID: @thread.ID, postID: @ID}
a = $.el 'a',
href: Build.postURL @board.ID, @thread.ID, @ID
className: if @isHidden then 'filtered backlink' else 'backlink'

View File

@ -1,6 +1,14 @@
QuoteYou =
init: ->
return unless g.VIEW in ['index', 'thread'] and Conf['Remember Your Posts'] and Conf['Quick Reply']
return unless g.VIEW in ['index', 'thread'] and Conf['Remember Your Posts']
@db = new DataBoard 'yourPosts'
$.sync 'Remember Your Posts', (enabled) -> Conf['Remember Your Posts'] = enabled
$.on d, 'QRPostSuccessful', (e) ->
$.forceSync 'Remember Your Posts'
if Conf['Remember Your Posts']
{boardID, threadID, postID} = e.detail
QuoteYou.db.set {boardID, threadID, postID, val: true}
if Conf['Highlight Own Posts']
$.addClass doc, 'highlight-own'
@ -20,13 +28,13 @@ QuoteYou =
node: ->
return if @isClone
if QR.db.get {boardID: @board.ID, threadID: @thread.ID, postID: @ID}
if QuoteYou.db.get {boardID: @board.ID, threadID: @thread.ID, postID: @ID}
$.addClass @nodes.root, 'yourPost'
# Stop there if there's no quotes in that post.
return unless @quotes.length
for quotelink in @nodes.quotelinks when QR.db.get Get.postDataFromLink quotelink
for quotelink in @nodes.quotelinks when QuoteYou.db.get Get.postDataFromLink quotelink
$.add quotelink, $.tn QuoteYou.text if Conf['Mark Quotes of You']
$.addClass quotelink, 'you'
$.addClass @nodes.root, 'quotesYou'