Browse Source

Fix post storing to orbit

develop
Apostolos Fanakis 4 years ago
parent
commit
8d5d4f738a
  1. 12
      packages/concordia-app/src/components/PostCreate/index.jsx

12
packages/concordia-app/src/components/PostCreate/index.jsx

@ -32,6 +32,7 @@ const PostCreate = (props) => {
const [postContentInputEmptySubmit, setPostContentInputEmptySubmit] = useState(false); const [postContentInputEmptySubmit, setPostContentInputEmptySubmit] = useState(false);
const [createPostCacheSendStackId, setCreatePostCacheSendStackId] = useState(''); const [createPostCacheSendStackId, setCreatePostCacheSendStackId] = useState('');
const [posting, setPosting] = useState(false); const [posting, setPosting] = useState(false);
const [storingPost, setStoringPost] = useState(false);
const userAddress = useSelector((state) => state.user.address); const userAddress = useSelector((state) => state.user.address);
const users = useSelector((state) => state.orbitData.users); const users = useSelector((state) => state.orbitData.users);
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -79,7 +80,7 @@ const PostCreate = (props) => {
}, [posting]); }, [posting]);
useEffect(() => { useEffect(() => {
if (posting && transactionStack && transactionStack[createPostCacheSendStackId] if (posting && !storingPost && transactionStack && transactionStack[createPostCacheSendStackId]
&& transactions[transactionStack[createPostCacheSendStackId]]) { && transactions[transactionStack[createPostCacheSendStackId]]) {
if (transactions[transactionStack[createPostCacheSendStackId]].status === TRANSACTION_ERROR) { if (transactions[transactionStack[createPostCacheSendStackId]].status === TRANSACTION_ERROR) {
setPosting(false); setPosting(false);
@ -99,14 +100,21 @@ const PostCreate = (props) => {
.then(() => { .then(() => {
setPostSubject(initialPostSubject); setPostSubject(initialPostSubject);
setPostContent(''); setPostContent('');
setPosting(false);
setPostSubjectInputEmptySubmit(false);
setPostContentInputEmptySubmit(false);
setCreatePostCacheSendStackId('');
}) })
.catch((reason) => { .catch((reason) => {
console.log(reason); console.log(reason);
}); });
setStoringPost(true);
} }
} }
}, [ }, [
createPostCacheSendStackId, initialPostSubject, postContent, postSubject, posting, transactionStack, transactions, createPostCacheSendStackId, initialPostSubject, postContent, postSubject, posting, storingPost, transactionStack,
transactions,
]); ]);
const savePost = useCallback(() => { const savePost = useCallback(() => {

Loading…
Cancel
Save