1
0
mirror of https://github.com/fazo96/ipfs-boards synced 2025-01-26 15:04:19 +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 { } else {
// Download via http api // Download via http api
try {
this.ipfs.cat(path, done) 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') done('this operation is not supported in limited mode')
} else { } else {
// Download via http api // Download via http api
try {
this.ipfs.ls(path, done) this.ipfs.ls(path, done)
} catch (e) {
done(e)
}
} }
} }

View File

@ -78,7 +78,7 @@ var Comment = React.createClass({
} }
}, },
getParentlink () { 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"> 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> <Icon name="level-up" /> <Link to={'/@' + this.props.adminID + '/' + this.props.board + '/' + this.props.post + '/' + this.props.comment.parent}>Parent</Link>
</div> </div>

View File

@ -12,23 +12,22 @@ module.exports = function (boardsAPI) {
}, },
componentDidMount: function () { componentDidMount: function () {
boardsAPI.use(boards => { boardsAPI.use(boards => {
boards.getEventEmitter().on('init', err => { boards.getEventEmitter().on('init', (err, limited) => {
if (!err && this.isMounted()) { if ((!err || limited) && this.isMounted()) {
this.init(boards) this.init(boards)
} }
}) })
if (this.isMounted() && boards.isInit) { if (boards.isInit || boards.limited) {
this.init(boards) this.init(boards)
} }
}) })
}, },
componentWillReceiveProps: function (nextProps) { componentWillReceiveProps: function (nextProps) {
if (this.props.params !== nextProps.params) { if (this.props.params !== nextProps.params) {
boardsAPI.use(boards => this.downloadComment(boards, nextProps)) boardsAPI.use(boards => this.init(boards, nextProps))
} }
}, },
downloadComment: function (boards, props) { 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) { if (err) {
this.setState({ this.setState({
@ -44,10 +43,9 @@ module.exports = function (boardsAPI) {
} }
}) })
}, },
init: function (boards) { init: function (boards, props) {
if (this.state.init) return this.setState({ comment: false, boards, api: true, allowReply: boards.isInit && !boards.limited })
this.setState({ api: true, boards, canReply: boards.isInit && !boards.limited }) this.downloadComment(boards, props || this.props)
this.downloadComment(boards, this.props)
}, },
getContext: function () { getContext: function () {
if (this.props.params.userid) { if (this.props.params.userid) {
@ -60,7 +58,8 @@ module.exports = function (boardsAPI) {
}, },
showComment: function () { showComment: function () {
if (this.state.comment) { 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 { } else {
return <div className="center-block text-center find-content"> return <div className="center-block text-center find-content">
<Icon name="refresh" className="fa-3x center-block light fa-spin" /> <Icon name="refresh" className="fa-3x center-block light fa-spin" />