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

fixed bug in comment view

This commit is contained in:
Enrico Fasoli 2015-12-12 13:21:14 +01:00
parent 013266b3f7
commit 2fc14841e4
2 changed files with 14 additions and 3 deletions

View File

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

View File

@ -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 <Comment 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">
return <div className="center-block text-center find-content">
<Icon name="refresh" className="fa-3x center-block light fa-spin" />
<h4>Finding content...</h4>
</div>