Skip to content

Commit a4e0e32

Browse files
committed
Sets page error checking and download button fixes
1 parent 05637bd commit a4e0e32

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/main/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ ipcMain.handle('retrieve-video-information', async (event, arg) => {
8383
}).then((output) => {
8484
// @ts-ignore
8585
return output.timestamp;
86+
}).catch((error) => {
87+
return error;
8688
});
8789
});
8890

src/renderer/components/VideoSearch.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useTheme } from '@mui/material/styles';
66
import { PropagateLoader } from 'react-spinners';
77
import { useNavigate } from 'react-router-dom';
88
import HiddenTextField from 'renderer/common/HiddenTextField';
9-
// import validator from 'validator';
9+
import SnackbarPopup from 'renderer/common/SnackbarPopup';
1010

1111
export interface VODMetadata {
1212
title: string;
@@ -37,6 +37,8 @@ const RetrieveSets = (
3737
}
3838

3939
const [waiting, setWaiting] = useState(false);
40+
const [errorMessage, setErrorMessage] = useState('');
41+
const [errorOpen, setErrorOpen] = useState(false);
4042

4143
const [getSets, { loading, error, data }] = useLazyQuery(
4244
GET_SETS_AT_STATION,
@@ -113,6 +115,10 @@ const RetrieveSets = (
113115
tournamentName: data.event.tournament.name,
114116
},
115117
});
118+
}).catch((err) => {
119+
setErrorMessage("Error retrieving sets: " + err.message);
120+
setErrorOpen(true);
121+
setWaiting(false);
116122
});
117123
}
118124
}, [data]);
@@ -127,6 +133,7 @@ const RetrieveSets = (
127133
justifyContent: 'center',
128134
}}
129135
>
136+
{SnackbarPopup(errorMessage, 'error', errorOpen, setErrorOpen)}
130137
<Button
131138
variant="contained"
132139
onClick={() => {

src/renderer/pages/SetsView.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ const SetsView = () => {
5050
const [errorMessage, setErrorMessage] = useState('');
5151
const [infoMessage, setInfoMessage] = useState('')
5252
const [downloaded, setDownloaded] = useState(false)
53+
const [enableDownload, setEnableDownload] = useState(false)
54+
55+
useEffect(() => {
56+
if (checked.length == location.state.sets.length + 1) {
57+
setEnableDownload(false)
58+
} else {
59+
setEnableDownload(true)
60+
}
61+
}, [checked])
5362

5463
const handleSelectAll = () => {
5564
let newChecked = [...checked];
@@ -319,13 +328,15 @@ const SetsView = () => {
319328
</List>
320329
<Box sx={{ display: 'flex', justifyContent: 'space-around', width: '100%' }}>
321330
<Button
331+
disabled={!enableDownload}
322332
variant="contained"
323333
color="secondary"
324334
sx={{ width: '27vw', marginTop: '20px', color: 'white' }}
325335
onClick={() => {
326336
setDownloaded(true)
327337
setInfoMessage('Your VODs are being downloaded to ./downloadedVODs/' + location.state.tournamentName);
328338
setInfoOpen(true)
339+
setEnableDownload(false)
329340
location.state.sets.map((set: VODMetadata) => {
330341
if (set.download) {
331342
console.log('Downloading set: ', set);
@@ -340,10 +351,12 @@ const SetsView = () => {
340351
.then((res: any) => {
341352
setSuccessMessage('Download complete: ' + set.title);
342353
setSuccessOpen(true);
354+
setEnableDownload(true);
343355
})
344356
.catch((err: any) => {
345357
setErrorMessage('Download failed: ' + err);
346358
setErrorOpen(true);
359+
setEnableDownload(true);
347360
});
348361
}
349362
});
@@ -361,6 +374,7 @@ const SetsView = () => {
361374
Open VOD Folder
362375
</Button>
363376
<Button
377+
disabled={!downloaded}
364378
variant="contained"
365379
color="secondary"
366380
sx={{ width: '27vw', marginTop: '20px', color: 'white' }}

0 commit comments

Comments
 (0)