diff --git a/package.json b/package.json index e674ce3..c463321 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "react-user-avatar": "^1.10.0", "redux": "^3.7.2", "redux-saga": "0.16.0", + "uuid": "^3.2.1", "web3": "^1.0.0-beta.34" }, "scripts": { diff --git a/src/assets/css/App.css b/src/assets/css/App.css index d87580a..781c76f 100644 --- a/src/assets/css/App.css +++ b/src/assets/css/App.css @@ -170,7 +170,7 @@ body, } .topic-form textarea { - height: 200px; + min-height: 200px; } .form-input-required { diff --git a/src/components/StartTopic.js b/src/components/StartTopic.js deleted file mode 100644 index 464eda5..0000000 --- a/src/components/StartTopic.js +++ /dev/null @@ -1,200 +0,0 @@ -import { drizzleConnect } from 'drizzle-react' -import React, { Component } from 'react' -import PropTypes from 'prop-types' - -import Post from './Post' - -const contract = "Forum"; -const contractMethod = "createTopic"; - -class StartTopic extends Component { - constructor(props, context) { - super(props); - - this.handleInputChange = this.handleInputChange.bind(this); - this.handlePreviewToggle = this.handlePreviewToggle.bind(this); - this.validateAndPost = this.validateAndPost.bind(this); - this.pushToDatabase = this.pushToDatabase.bind(this); - - this.transactionProgressText = []; - this.drizzle = context.drizzle; - - this.state = { - topicSubjectInput: '', - topicMessageInput: '', - topicSubjectInputEmptySubmit: false, - topicMessageInputEmptySubmit: false, - previewEnabled: false, - previewDate: "", - creatingTopic: false, - transactionState: null, - savingToOrbitDB: null - }; - } - - async validateAndPost() { - if (this.state.topicSubjectInput === '' || this.state.topicMessageInput === ''){ - this.setState({ - topicSubjectInputEmptySubmit: this.state.topicSubjectInput === '', - topicMessageInputEmptySubmit: this.state.topicMessageInput === '' - }); - return; - } - - this.stackId = this.drizzle.contracts[contract].methods[contractMethod].cacheSend(); - this.transactionProgressText.push(
); - this.transactionProgressText.push("Waiting for transaction acceptance..."); - this.setState({ - 'creatingTopic': true, - 'transactionState': "ACCEPTANCE_PENDING" - }); - } - - async pushToDatabase() { - await this.props.orbitDB.topicsDB.put(this.topicIDFetched, { - subject: this.state.topicSubjectInput, - content: this.state.topicMessageInput - }); - this.setState({'savingToOrbitDB': "SUCCESS"}); - } - - handleInputChange(event) { - this.setState({[event.target.name]: event.target.value}); - } - - handlePreviewToggle() { - this.setState((prevState, props) => ({ - previewEnabled: !prevState.previewEnabled, - previewDate: this.getDate() - })); - } - - getDate() { - const currentdate = new Date(); - return ((currentdate.getMonth() + 1) + " " - + currentdate.getDate() + ", " - + currentdate.getFullYear() + ", " - + currentdate.getHours() + ":" - + currentdate.getMinutes() + ":" - + currentdate.getSeconds()); - } - - render() { - return( -
- {this.state.creatingTopic &&
-
-

-
- {this.transactionProgressText} -
-
- } -
-

- -

-
- {this.state.previewEnabled && - } -
- {!this.state.previewEnabled && - [ - , -