From 519417b6ec955e129d01b936ea3ba998ffcc0573 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Wed, 23 Dec 2015 17:07:53 +0100 Subject: [PATCH] fix #72 --- lib/boards-api.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/boards-api.js b/lib/boards-api.js index f6d78dd..eebb290 100644 --- a/lib/boards-api.js +++ b/lib/boards-api.js @@ -691,7 +691,6 @@ BoardsAPI.prototype.downloadComment = function (hash, adminID, board, target, do done = target target = undefined } - console.log('target', target) this.cat(hash, (err2, r) => { if (err2) { this.ee.emit('error', err2) @@ -713,9 +712,9 @@ BoardsAPI.prototype.downloadComment = function (hash, adminID, board, target, do return this.ee } -BoardsAPI.prototype.getCommentsFor = function (parent, board, adminID, target) { +BoardsAPI.prototype.getCommentsFor = function (parent, board, adminID, target, list = [parent]) { if (!parent || !board || !adminID) { - return console.log('malformed arguments:', parent, board, adminID) + return console.log('malformed arguments:', parent, board, adminID, target, list) } // figure out if there's a previous version of the item this.cat(parent, (err, res) => { @@ -725,9 +724,9 @@ BoardsAPI.prototype.getCommentsFor = function (parent, board, adminID, target) { replyAsObj(res, true, (err2, obj) => { if (err2) { this.ee.emit('error', err2) - } else if (typeof obj.previous === 'string') { + } else if (typeof obj.previous === 'string' && list.indexOf(obj.previous) < 0) { // Also get comments for the previous version of the parent! - this.getCommentsFor(obj.previous, board, adminID, parent) + this.getCommentsFor(obj.previous, board, adminID, (target || parent), list.concat(obj.previous)) } }) }