mirror of
https://github.com/fazo96/ipfs-boards
synced 2025-01-10 12:24:20 +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())
|
||||
post.hash = hash
|
||||
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)
|
||||
if(done && done.apply) done(null,post)
|
||||
}
|
||||
@ -327,6 +330,7 @@ BoardsAPI.prototype.getAllowedContentProducers = function(adminID,board,options)
|
||||
}
|
||||
|
||||
BoardsAPI.prototype.getPostsInBoard = function(adminID,board){
|
||||
if(adminID){
|
||||
this.ee.on('approved posts for '+board+'@'+adminID,ret => {
|
||||
// Automatically download approved posts
|
||||
ret.forEach(item => this.downloadPost(item.hash,adminID,board))
|
||||
@ -338,6 +342,15 @@ BoardsAPI.prototype.getPostsInBoard = function(adminID,board){
|
||||
} else res.forEach(item => this.downloadPost(item.hash,adminID,board,adminID))
|
||||
})
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,7 @@ ReactDOM.render(
|
||||
</Route>
|
||||
</Route>
|
||||
<Route path="/post/:posthash" component={PostPage} />
|
||||
<Route path="/board/:boardname" component={Board} />
|
||||
<Route path="/users" component={Users} />
|
||||
<Route path="/settings" component={Settings} />
|
||||
<Route path="*" component={NotFound} />
|
||||
|
@ -28,20 +28,23 @@ module.exports = function(boardsAPI){
|
||||
this.init(boards)
|
||||
}
|
||||
})
|
||||
if(this.props.params.userid){
|
||||
ee.on('settings for '+this.props.params.boardname+'@'+this.props.params.userid, (res) => {
|
||||
if(!this.isMounted()) return true
|
||||
console.log('Found name:',res.fullname)
|
||||
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){
|
||||
this.setState({api: true})
|
||||
this.init(boards)
|
||||
boards.getBoardSettings(this.props.params.userid,this.props.params.boardname)
|
||||
}
|
||||
})
|
||||
},
|
||||
init: function(boards){
|
||||
if(!this.state.init){
|
||||
if(this.props.params.userid)
|
||||
boards.getBoardSettings(this.props.params.userid,this.props.params.boardname)
|
||||
this.setState({ init: true })
|
||||
}
|
||||
@ -51,7 +54,8 @@ module.exports = function(boardsAPI){
|
||||
return (<div className="board">
|
||||
<h2>{this.state.name}</h2>
|
||||
<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}/>
|
||||
</div>)
|
||||
} else return <GetIPFS />
|
||||
|
@ -14,7 +14,7 @@ module.exports = function(boardsAPI){
|
||||
init: function(boards){
|
||||
this.setState({ api: true })
|
||||
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
|
||||
var now = (new Date()).getTime()
|
||||
var posts = this.state.posts
|
||||
|
Loading…
Reference in New Issue
Block a user