|
@ -9,6 +9,8 @@ import { useHistory } from 'react-router'; |
|
|
import { useSelector } from 'react-redux'; |
|
|
import { useSelector } from 'react-redux'; |
|
|
import './styles.css'; |
|
|
import './styles.css'; |
|
|
import { drizzle, breeze } from '../../../redux/store'; |
|
|
import { drizzle, breeze } from '../../../redux/store'; |
|
|
|
|
|
import { TRANSACTION_ERROR, TRANSACTION_SUCCESS } from '../../../constants/TransactionStatus'; |
|
|
|
|
|
import { POSTS_DATABASE, TOPICS_DATABASE } from '../../../constants/OrbitDatabases'; |
|
|
|
|
|
|
|
|
const { contracts: { Forum: { methods: { createTopic } } } } = drizzle; |
|
|
const { contracts: { Forum: { methods: { createTopic } } } } = drizzle; |
|
|
const { orbit: { stores } } = breeze; |
|
|
const { orbit: { stores } } = breeze; |
|
@ -47,9 +49,9 @@ const TopicCreate = (props) => { |
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
if (posting && transactionStack && transactionStack[createTopicCacheSendStackId] |
|
|
if (posting && transactionStack && transactionStack[createTopicCacheSendStackId] |
|
|
&& transactions[transactionStack[createTopicCacheSendStackId]]) { |
|
|
&& transactions[transactionStack[createTopicCacheSendStackId]]) { |
|
|
if (transactions[transactionStack[createTopicCacheSendStackId]].status === 'error') { |
|
|
if (transactions[transactionStack[createTopicCacheSendStackId]].status === TRANSACTION_ERROR) { |
|
|
setPosting(false); |
|
|
setPosting(false); |
|
|
} else if (transactions[transactionStack[createTopicCacheSendStackId]].status === 'success') { |
|
|
} else if (transactions[transactionStack[createTopicCacheSendStackId]].status === TRANSACTION_SUCCESS) { |
|
|
const { |
|
|
const { |
|
|
receipt: { |
|
|
receipt: { |
|
|
events: { |
|
|
events: { |
|
@ -63,8 +65,8 @@ const TopicCreate = (props) => { |
|
|
}, |
|
|
}, |
|
|
} = transactions[transactionStack[createTopicCacheSendStackId]]; |
|
|
} = transactions[transactionStack[createTopicCacheSendStackId]]; |
|
|
|
|
|
|
|
|
const topicsDb = Object.values(stores).find((store) => store.dbname === 'topics'); |
|
|
const topicsDb = Object.values(stores).find((store) => store.dbname === TOPICS_DATABASE); |
|
|
const postsDb = Object.values(stores).find((store) => store.dbname === 'posts'); |
|
|
const postsDb = Object.values(stores).find((store) => store.dbname === POSTS_DATABASE); |
|
|
|
|
|
|
|
|
topicsDb |
|
|
topicsDb |
|
|
.put(topicId, { subject: subjectInput }, { pin: true }) |
|
|
.put(topicId, { subject: subjectInput }, { pin: true }) |
|
|