1
0
mirror of https://github.com/fazo96/ipfs-boards synced 2025-01-10 12:24:20 +01:00

bugfixing

This commit is contained in:
Enrico Fasoli 2015-12-23 13:19:23 +01:00
parent 047dad1c4c
commit 0cf95a7897
3 changed files with 20 additions and 13 deletions

View File

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

View File

@ -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 <div className="inline not-first">
<Icon name="level-up" /> <Link to={'/@' + this.props.adminID + '/' + this.props.board + '/' + this.props.post + '/' + this.props.comment.parent}>Parent</Link>
</div>

View File

@ -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 <Comment canReply={this.state.canReply} comment={this.state.comment} post={this.props.params.posthash} adminID={this.props.params.userid} board={this.props.params.boardname} showParent={true} api={this.state.boards} />
console.log('allowReply', this.state.allowReply)
return <Comment allowReply={this.state.allowReply} comment={this.state.comment} post={this.props.params.posthash} adminID={this.props.params.userid} board={this.props.params.boardname} showParent={true} api={this.state.boards} />
} else {
return <div className="center-block text-center find-content">
<Icon name="refresh" className="fa-3x center-block light fa-spin" />