From 8d5d4f738ac5d793591eea1372f7deeec97eb94f Mon Sep 17 00:00:00 2001 From: Apostolof Date: Thu, 19 Nov 2020 22:46:54 +0200 Subject: [PATCH] Fix post storing to orbit --- .../src/components/PostCreate/index.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/concordia-app/src/components/PostCreate/index.jsx b/packages/concordia-app/src/components/PostCreate/index.jsx index b84217b..0047247 100644 --- a/packages/concordia-app/src/components/PostCreate/index.jsx +++ b/packages/concordia-app/src/components/PostCreate/index.jsx @@ -32,6 +32,7 @@ const PostCreate = (props) => { const [postContentInputEmptySubmit, setPostContentInputEmptySubmit] = useState(false); const [createPostCacheSendStackId, setCreatePostCacheSendStackId] = useState(''); const [posting, setPosting] = useState(false); + const [storingPost, setStoringPost] = useState(false); const userAddress = useSelector((state) => state.user.address); const users = useSelector((state) => state.orbitData.users); const dispatch = useDispatch(); @@ -79,7 +80,7 @@ const PostCreate = (props) => { }, [posting]); useEffect(() => { - if (posting && transactionStack && transactionStack[createPostCacheSendStackId] + if (posting && !storingPost && transactionStack && transactionStack[createPostCacheSendStackId] && transactions[transactionStack[createPostCacheSendStackId]]) { if (transactions[transactionStack[createPostCacheSendStackId]].status === TRANSACTION_ERROR) { setPosting(false); @@ -99,14 +100,21 @@ const PostCreate = (props) => { .then(() => { setPostSubject(initialPostSubject); setPostContent(''); + setPosting(false); + setPostSubjectInputEmptySubmit(false); + setPostContentInputEmptySubmit(false); + setCreatePostCacheSendStackId(''); }) .catch((reason) => { console.log(reason); }); + + setStoringPost(true); } } }, [ - createPostCacheSendStackId, initialPostSubject, postContent, postSubject, posting, transactionStack, transactions, + createPostCacheSendStackId, initialPostSubject, postContent, postSubject, posting, storingPost, transactionStack, + transactions, ]); const savePost = useCallback(() => {