1
0
mirror of https://github.com/fazo96/ipfs-boards synced 2025-01-24 14:44:19 +01:00
This commit is contained in:
Enrico Fasoli 2015-12-23 17:07:53 +01:00
parent 6b54ec8b30
commit 519417b6ec

View File

@ -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))
}
})
}