show errors on connection?!

stable
Valerie 2021-08-23 14:21:42 -04:00
parent 5588f04b7e
commit 0214e0c86b
1 changed files with 11 additions and 4 deletions

View File

@ -36,6 +36,7 @@ const useMounted = () => {
const App = () => { const App = () => {
const [connected, setConnected] = useState(false); const [connected, setConnected] = useState(false);
const [columns, rows] = useStdoutDimensions(); const [columns, rows] = useStdoutDimensions();
const [error, setError] = useState(null);
const { exit } = useApp(); const { exit } = useApp();
useEffect(() => { useEffect(() => {
@ -51,6 +52,8 @@ const App = () => {
useUnifiedTopology: true useUnifiedTopology: true
}).then(() => new Promise(res => setTimeout(res, 1000))).then(() => { }).then(() => new Promise(res => setTimeout(res, 1000))).then(() => {
setConnected(true); setConnected(true);
}).catch(e => {
setError(e);
}) })
}, []); }, []);
@ -61,15 +64,19 @@ const App = () => {
height={rows} height={rows}
width={columns} width={columns}
> >
{!connected && {(!connected) && (
<Box <Box
alignItems="center" alignItems="center"
justifyContent="center" justifyContent="center"
width="100%" width="100%"
> >
<Text>Connecting to Task Database...</Text> {(error) && (
<Text>{error.message}</Text>
) || (
<Text>Connecting to Task Database...</Text>
)}
</Box> </Box>
|| ) || (
<Multiview <Multiview
screens={[ screens={[
{ {
@ -82,7 +89,7 @@ const App = () => {
} }
]} ]}
/> />
} )}
</Box> </Box>
);;; );;;
}; };