diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-08-17 19:33:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-17 19:33:53 +0300 |
commit | 6c9ee57d83d30d598062cfa95a73555808e04e7f (patch) | |
tree | dde56a20e1a18b64cc93bc408981a65ee5f7a427 /src/containers | |
parent | 0a42a6d26fad6d878e4135b218166872c6b6687b (diff) | |
parent | 3b72a38197b1a1cff1c059ed5c55bf9f9d50569d (diff) | |
download | which-ui-6c9ee57d83d30d598062cfa95a73555808e04e7f.tar.gz |
Merge pull request #89 from which-ecosystem/bugs
Bug fixes
Diffstat (limited to 'src/containers')
-rw-r--r-- | src/containers/PollCreation/PollCreation.tsx | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/containers/PollCreation/PollCreation.tsx b/src/containers/PollCreation/PollCreation.tsx index 107314a..489c12a 100644 --- a/src/containers/PollCreation/PollCreation.tsx +++ b/src/containers/PollCreation/PollCreation.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import Bluebird from 'bluebird'; import { useHistory } from 'react-router-dom'; import { makeStyles } from '@material-ui/core/styles'; import { @@ -49,21 +50,22 @@ const PollCreation: React.FC = () => { } = useS3Preupload(); const handleClick = async () => { - if (isLeftReady && isRightReady) { - const [leftUrl, rightUrl] = await Promise.all([resolveLeft(), resolveRight()]); + try { + const [leftUrl, rightUrl] = await Bluebird.all([resolveLeft(), resolveRight()]); const contents = { left: { url: leftUrl }, right: { url: rightUrl } }; + history.push('/feed'); + post('/polls/', { contents }).then(() => { updateFeed(); - enqueueSnackbar('Your poll has been successfully created!', { - variant: 'success' - }); + enqueueSnackbar('Your poll has been successfully created!', { variant: 'success' }); }); - + } catch (error) { + enqueueSnackbar('Failed to create a poll. Please, try again.', { variant: 'error' }); history.push('/feed'); } }; |