mirror of
https://github.com/fazo96/ipfs-boards
synced 2025-01-25 14:54:19 +01:00
unfiltered board view implemented
This commit is contained in:
parent
4ae055be45
commit
5794ac3d4c
@ -281,7 +281,10 @@ BoardsAPI.prototype.downloadPost = function(hash,adminID,board,op,done){
|
|||||||
var post = JSON.parse(r.toString())
|
var post = JSON.parse(r.toString())
|
||||||
post.hash = hash
|
post.hash = hash
|
||||||
if(op) post.op = op // Inject op
|
if(op) post.op = op // Inject op
|
||||||
if(board) this.ee.emit('post in '+board+'@'+adminID,post,hash)
|
if(board){
|
||||||
|
if(adminID) this.ee.emit('post in '+board+'@'+adminID,post,hash)
|
||||||
|
else this.ee.emit('post in '+board,post,hash)
|
||||||
|
}
|
||||||
this.ee.emit(hash,post,adminID,board)
|
this.ee.emit(hash,post,adminID,board)
|
||||||
if(done && done.apply) done(null,post)
|
if(done && done.apply) done(null,post)
|
||||||
}
|
}
|
||||||
@ -327,17 +330,27 @@ BoardsAPI.prototype.getAllowedContentProducers = function(adminID,board,options)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BoardsAPI.prototype.getPostsInBoard = function(adminID,board){
|
BoardsAPI.prototype.getPostsInBoard = function(adminID,board){
|
||||||
this.ee.on('approved posts for '+board+'@'+adminID,ret => {
|
if(adminID){
|
||||||
// Automatically download approved posts
|
this.ee.on('approved posts for '+board+'@'+adminID,ret => {
|
||||||
ret.forEach(item => this.downloadPost(item.hash,adminID,board))
|
// Automatically download approved posts
|
||||||
})
|
ret.forEach(item => this.downloadPost(item.hash,adminID,board))
|
||||||
// Get the admin's posts
|
})
|
||||||
this.getUserPostListInBoard(adminID,board,(err,res) => {
|
// Get the admin's posts
|
||||||
if(err){
|
this.getUserPostListInBoard(adminID,board,(err,res) => {
|
||||||
console.log(err)
|
if(err){
|
||||||
} else res.forEach(item => this.downloadPost(item.hash,adminID,board,adminID))
|
console.log(err)
|
||||||
})
|
} else res.forEach(item => this.downloadPost(item.hash,adminID,board,adminID))
|
||||||
this.getAllowedContentProducers(adminID,board,{ posts: true })
|
})
|
||||||
|
this.getAllowedContentProducers(adminID,board,{ posts: true })
|
||||||
|
} else {
|
||||||
|
// TODO: Download all posts in board from everyone
|
||||||
|
// Download my posts
|
||||||
|
this.getUserPostListInBoard(this.id,board,(err,res) => {
|
||||||
|
if(err){
|
||||||
|
console.log(err)
|
||||||
|
} else res.forEach(item => this.downloadPost(item.hash,undefined,board,this.id))
|
||||||
|
})
|
||||||
|
}
|
||||||
return this.ee
|
return this.ee
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +90,7 @@ ReactDOM.render(
|
|||||||
</Route>
|
</Route>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/post/:posthash" component={PostPage} />
|
<Route path="/post/:posthash" component={PostPage} />
|
||||||
|
<Route path="/board/:boardname" component={Board} />
|
||||||
<Route path="/users" component={Users} />
|
<Route path="/users" component={Users} />
|
||||||
<Route path="/settings" component={Settings} />
|
<Route path="/settings" component={Settings} />
|
||||||
<Route path="*" component={NotFound} />
|
<Route path="*" component={NotFound} />
|
||||||
|
@ -28,21 +28,24 @@ module.exports = function(boardsAPI){
|
|||||||
this.init(boards)
|
this.init(boards)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
ee.on('settings for '+this.props.params.boardname+'@'+this.props.params.userid, (res) => {
|
if(this.props.params.userid){
|
||||||
if(!this.isMounted()) return true
|
ee.on('settings for '+this.props.params.boardname+'@'+this.props.params.userid, (res) => {
|
||||||
console.log('Found name:',res.fullname)
|
if(!this.isMounted()) return true
|
||||||
this.setState({ name: res.fullname.trim(), description: res.description })
|
if(res) this.setState({ name: res.fullname, description: res.description })
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
this.setState({ description: 'All the messages posted in __#'+this.props.params.boardname+'__' })
|
||||||
|
}
|
||||||
if(boards.isInit || this.state.api){
|
if(boards.isInit || this.state.api){
|
||||||
this.setState({api: true})
|
this.setState({api: true})
|
||||||
this.init(boards)
|
this.init(boards)
|
||||||
boards.getBoardSettings(this.props.params.userid,this.props.params.boardname)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
init: function(boards){
|
init: function(boards){
|
||||||
if(!this.state.init){
|
if(!this.state.init){
|
||||||
boards.getBoardSettings(this.props.params.userid,this.props.params.boardname)
|
if(this.props.params.userid)
|
||||||
|
boards.getBoardSettings(this.props.params.userid,this.props.params.boardname)
|
||||||
this.setState({ init: true })
|
this.setState({ init: true })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -51,7 +54,8 @@ module.exports = function(boardsAPI){
|
|||||||
return (<div className="board">
|
return (<div className="board">
|
||||||
<h2>{this.state.name}</h2>
|
<h2>{this.state.name}</h2>
|
||||||
<Markdown source={this.state.description} skipHtml={true} />
|
<Markdown source={this.state.description} skipHtml={true} />
|
||||||
<h5><UserID id={this.props.params.userid} /></h5>
|
{this.props.params.userid?<h5><UserID id={this.props.params.userid} /></h5>:<p></p>}
|
||||||
|
<hr />
|
||||||
<PostList board={this.props.params.boardname} admin={this.props.params.userid}/>
|
<PostList board={this.props.params.boardname} admin={this.props.params.userid}/>
|
||||||
</div>)
|
</div>)
|
||||||
} else return <GetIPFS />
|
} else return <GetIPFS />
|
||||||
|
@ -14,7 +14,7 @@ module.exports = function(boardsAPI){
|
|||||||
init: function(boards){
|
init: function(boards){
|
||||||
this.setState({ api: true })
|
this.setState({ api: true })
|
||||||
boards.getPostsInBoard(this.props.admin,this.props.board)
|
boards.getPostsInBoard(this.props.admin,this.props.board)
|
||||||
.on('post in '+this.props.board+'@'+this.props.admin,(post,hash) => {
|
.on('post in '+this.props.board+(this.props.admin?'@'+this.props.admin:''),(post,hash) => {
|
||||||
if(!this.isMounted()) return true
|
if(!this.isMounted()) return true
|
||||||
var now = (new Date()).getTime()
|
var now = (new Date()).getTime()
|
||||||
var posts = this.state.posts
|
var posts = this.state.posts
|
||||||
|
Loading…
Reference in New Issue
Block a user