mirror of
https://github.com/fazo96/ipfs-boards
synced 2025-01-25 14:54:19 +01:00
fixed bug in comment view
This commit is contained in:
parent
013266b3f7
commit
2fc14841e4
@ -384,17 +384,28 @@ BoardsAPI.prototype.getUserPostListInBoard = function(user,board,done){
|
|||||||
return this.ee
|
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) => {
|
this.ipfs.cat(hash,(err2,r) => {
|
||||||
if(err2){
|
if(err2){
|
||||||
this.ee.emit('error',err2)
|
this.ee.emit('error',err2)
|
||||||
console.log('Could not download comment',hash,'of',board+'@'+adminID)
|
console.log('Could not download comment',hash,'of',board+'@'+adminID)
|
||||||
|
if(done) done(err2)
|
||||||
} else {
|
} else {
|
||||||
// TODO: add JSON parsing error handling
|
// TODO: add JSON parsing error handling
|
||||||
var cmnt = JSON.parse(r.toString())
|
var cmnt = JSON.parse(r.toString())
|
||||||
cmnt.hash = hash
|
cmnt.hash = hash
|
||||||
|
if(target){
|
||||||
|
cmnt.original_parent = cmnt.parent
|
||||||
|
cmnt.parent = target
|
||||||
|
}
|
||||||
this.ee.emit(hash,cmnt,adminID,board)
|
this.ee.emit(hash,cmnt,adminID,board)
|
||||||
this.ee.emit('comment for '+(target || cmnt.parent),cmnt)
|
this.ee.emit('comment for '+(target || cmnt.parent),cmnt)
|
||||||
|
if(done) done(null,cmnt)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return this.ee
|
return this.ee
|
||||||
|
@ -29,7 +29,7 @@ module.exports = function(boardsAPI){
|
|||||||
},
|
},
|
||||||
downloadComment: function(boards,props){
|
downloadComment: function(boards,props){
|
||||||
this.setState({ comment: false })
|
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({ comment: { title: 'Error', text: err.Message || err.Error }})
|
this.setState({ comment: { title: 'Error', text: err.Message || err.Error }})
|
||||||
} else {
|
} else {
|
||||||
@ -54,7 +54,7 @@ module.exports = function(boardsAPI){
|
|||||||
if(this.state.comment){
|
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} />
|
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 {
|
} 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" />
|
<Icon name="refresh" className="fa-3x center-block light fa-spin" />
|
||||||
<h4>Finding content...</h4>
|
<h4>Finding content...</h4>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user