From 0cf95a78972a7d0089598986ef359a6adbe23ce5 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Wed, 23 Dec 2015 13:19:23 +0100 Subject: [PATCH] bugfixing --- lib/boards-api.js | 12 ++++++++++-- webapp/components/comment.jsx | 2 +- webapp/pages/commentpage.jsx | 19 +++++++++---------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/boards-api.js b/lib/boards-api.js index f2842b2..f6d78dd 100644 --- a/lib/boards-api.js +++ b/lib/boards-api.js @@ -314,7 +314,11 @@ BoardsAPI.prototype.cat = function (path, done) { }) } else { // Download via http api - this.ipfs.cat(path, done) + try { + this.ipfs.cat(path, done) + } catch (e) { + done(e) + } } } @@ -324,7 +328,11 @@ BoardsAPI.prototype.ls = function (path, done) { done('this operation is not supported in limited mode') } else { // Download via http api - this.ipfs.ls(path, done) + try { + this.ipfs.ls(path, done) + } catch (e) { + done(e) + } } } diff --git a/webapp/components/comment.jsx b/webapp/components/comment.jsx index 6f7b362..675337c 100644 --- a/webapp/components/comment.jsx +++ b/webapp/components/comment.jsx @@ -78,7 +78,7 @@ var Comment = React.createClass({ } }, getParentlink () { - if (this.props.showParent && this.props.comment.parent && this.props.comment.parent !== this.props.post) { + if (this.props.showParent && this.props.comment.parent) { return
Parent
diff --git a/webapp/pages/commentpage.jsx b/webapp/pages/commentpage.jsx index 3d3d403..8fc3d7e 100644 --- a/webapp/pages/commentpage.jsx +++ b/webapp/pages/commentpage.jsx @@ -12,23 +12,22 @@ module.exports = function (boardsAPI) { }, componentDidMount: function () { boardsAPI.use(boards => { - boards.getEventEmitter().on('init', err => { - if (!err && this.isMounted()) { + boards.getEventEmitter().on('init', (err, limited) => { + if ((!err || limited) && this.isMounted()) { this.init(boards) } }) - if (this.isMounted() && boards.isInit) { + if (boards.isInit || boards.limited) { this.init(boards) } }) }, componentWillReceiveProps: function (nextProps) { if (this.props.params !== nextProps.params) { - boardsAPI.use(boards => this.downloadComment(boards, nextProps)) + boardsAPI.use(boards => this.init(boards, nextProps)) } }, downloadComment: function (boards, props) { - this.setState({ comment: false }) boards.downloadComment(props.params.commenthash, props.params.userid, props.params.boardname, (err, comment) => { if (err) { this.setState({ @@ -44,10 +43,9 @@ module.exports = function (boardsAPI) { } }) }, - init: function (boards) { - if (this.state.init) return - this.setState({ api: true, boards, canReply: boards.isInit && !boards.limited }) - this.downloadComment(boards, this.props) + init: function (boards, props) { + this.setState({ comment: false, boards, api: true, allowReply: boards.isInit && !boards.limited }) + this.downloadComment(boards, props || this.props) }, getContext: function () { if (this.props.params.userid) { @@ -60,7 +58,8 @@ module.exports = function (boardsAPI) { }, showComment: function () { if (this.state.comment) { - return + console.log('allowReply', this.state.allowReply) + return } else { return