From a22ca7a3f3785534944311ef5eb2f1ee802f0748 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Thu, 28 Jan 2016 19:45:04 -0800 Subject: [PATCH] Remove dependence of 'Remember Your Posts' suboptions on 'Quick Reply'. #677 --- src/Miscellaneous/Keybinds.coffee | 4 ++-- src/Monitoring/ThreadWatcher.coffee | 8 ++++---- src/Monitoring/Unread.coffee | 6 +++--- src/Posting/QR.coffee | 12 ------------ src/Quotelinks/QuoteBacklink.coffee | 2 +- src/Quotelinks/QuoteYou.coffee | 14 +++++++++++--- 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index 2520e135f..dc62900d3 100644 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -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' diff --git a/src/Monitoring/ThreadWatcher.coffee b/src/Monitoring/ThreadWatcher.coffee index 28ac1e682..662094edb 100644 --- a/src/Monitoring/ThreadWatcher.coffee +++ b/src/Monitoring/ThreadWatcher.coffee @@ -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 = /]*\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 diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index 0e67a138e..e4e066c94 100644 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -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 diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 33739d8a9..47ca5f861 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -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 diff --git a/src/Quotelinks/QuoteBacklink.coffee b/src/Quotelinks/QuoteBacklink.coffee index 17a5952df..b3a1e4cbe 100644 --- a/src/Quotelinks/QuoteBacklink.coffee +++ b/src/Quotelinks/QuoteBacklink.coffee @@ -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' diff --git a/src/Quotelinks/QuoteYou.coffee b/src/Quotelinks/QuoteYou.coffee index 17621b771..3838b0def 100644 --- a/src/Quotelinks/QuoteYou.coffee +++ b/src/Quotelinks/QuoteYou.coffee @@ -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'