From 868fe50675a5f66cc9e77c29399c5676fea7573a Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Thu, 26 Nov 2015 19:35:34 +0100 Subject: [PATCH] forgot a file... damn --- webapp/components/commentpage.jsx | 68 +++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 webapp/components/commentpage.jsx diff --git a/webapp/components/commentpage.jsx b/webapp/components/commentpage.jsx new file mode 100644 index 0000000..e7b29b5 --- /dev/null +++ b/webapp/components/commentpage.jsx @@ -0,0 +1,68 @@ +var React = require('react') +var Link = require('react-router').Link +var Icon = require('icon.jsx') + +module.exports = function(boardsAPI){ + var UserID = require('userID.jsx')(boardsAPI) + var GetIPFS = require('getipfs.jsx')(boardsAPI) + var Post = require('post.jsx')(boardsAPI) + var Comment = require('comment.jsx')(boardsAPI) + + return React.createClass({ + getInitialState: function(){ + return { parent: false, api: false } + }, + componentDidMount: function(){ + boardsAPI.use(boards => { + boards.init() + boards.getEventEmitter().on('init', err => { + if(!err && this.isMounted()){ + this.init(boards) + } + }) + if(this.isMounted() && boards.isInit){ + this.init(boards) + } + }) + }, + init: function(boards){ + if(this.state.init) return + this.setState({ api: true }) + boards.downloadComment(this.props.params.commenthash,this.props.params.userid,this.props.params.boardname,(err,comment) => { + if(err){ + this.setState({ comment: { title: 'Error', text: err.Message || err.Error }}) + } else { + this.setState({ comment }) + } + }) + }, + getContext: function(){ + if(this.props.params.userid){ + if(this.props.params.boardname) + return
Comment by in #{this.props.params.boardname} to {this.props.params.posthash}
+ else + return
Comment by
+ } else return
You are viewing a single comment
+ }, + showComment: function(){ + if(this.state.comment){ + return + } else { + return
+ +

Finding content...

+
+ } + }, + render: function(){ + if(this.state.api) + return
+
+ {this.getContext()} +
+ {this.showComment()} +
+ else return + } + }) +}