From 67b134c20f3329334f8583148e85b9c0847a3aa4 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Mon, 28 Mar 2016 01:55:33 -0700 Subject: [PATCH] Identify context of upvote when quoting multiple posts. --- src/Quotelinks/Upvotes.coffee | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Quotelinks/Upvotes.coffee b/src/Quotelinks/Upvotes.coffee index fa5120698..5f0d2307c 100644 --- a/src/Quotelinks/Upvotes.coffee +++ b/src/Quotelinks/Upvotes.coffee @@ -4,6 +4,7 @@ Upvotes = init: -> return unless g.VIEW is 'thread' and Conf['Upvotes'] + @regexp = new RegExp "(?:^>.*\\n)+\\s*#{@text}", 'gm' Post.callbacks.push name: 'Upvotes' cb: @node @@ -26,8 +27,12 @@ Upvotes = Upvotes.count[@fullID] = 0 - if @quotes.length is 1 and @info.comment.indexOf(Upvotes.text) >= 0 - Upvotes.increment @quotes[0] + quotes = {} + for context in @info.comment.match(Upvotes.regexp) or [] + for quote in context.match(/>>\d+/g) or [] + quotes[quote[2..]] = true + for quote of quotes + Upvotes.increment "#{g.BOARD}.#{quote}" increment: (fullID) -> return unless fullID of Upvotes.count