From 2fc14841e456cd8dce3f8bb4ef31a012ef5f4a62 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Sat, 12 Dec 2015 13:21:14 +0100 Subject: [PATCH] fixed bug in comment view --- lib/boards-api.js | 13 ++++++++++++- webapp/pages/commentpage.jsx | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/boards-api.js b/lib/boards-api.js index b940c27..bc1b5a3 100644 --- a/lib/boards-api.js +++ b/lib/boards-api.js @@ -384,17 +384,28 @@ BoardsAPI.prototype.getUserPostListInBoard = function(user,board,done){ return this.ee } -BoardsAPI.prototype.downloadComment = function(hash,adminID,board,target){ +BoardsAPI.prototype.downloadComment = function(hash,adminID,board,target,done){ + if(!done && typeof target == 'function'){ + done = target + target = undefined + } + console.log('target',target) this.ipfs.cat(hash,(err2,r) => { if(err2){ this.ee.emit('error',err2) console.log('Could not download comment',hash,'of',board+'@'+adminID) + if(done) done(err2) } else { // TODO: add JSON parsing error handling var cmnt = JSON.parse(r.toString()) cmnt.hash = hash + if(target){ + cmnt.original_parent = cmnt.parent + cmnt.parent = target + } this.ee.emit(hash,cmnt,adminID,board) this.ee.emit('comment for '+(target || cmnt.parent),cmnt) + if(done) done(null,cmnt) } }) return this.ee diff --git a/webapp/pages/commentpage.jsx b/webapp/pages/commentpage.jsx index 34f81c7..e33a3f0 100644 --- a/webapp/pages/commentpage.jsx +++ b/webapp/pages/commentpage.jsx @@ -29,7 +29,7 @@ module.exports = function(boardsAPI){ }, downloadComment: function(boards,props){ this.setState({ comment: false }) - boards.downloadComment(props.params.commenthash,props.params.userid,props.params.boardname,(err,comment) => { + boards.downloadComment(props.params.commenthash,props.params.userid,props.params.boardname, (err,comment) => { if(err){ this.setState({ comment: { title: 'Error', text: err.Message || err.Error }}) } else { @@ -54,7 +54,7 @@ module.exports = function(boardsAPI){ if(this.state.comment){ return } else { - return
+ return

Finding content...