Skip to content

Commit

Permalink
Sets page error checking and download button fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-yao committed Feb 10, 2023
1 parent 05637bd commit a4e0e32
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ ipcMain.handle('retrieve-video-information', async (event, arg) => {
}).then((output) => {
// @ts-ignore
return output.timestamp;
}).catch((error) => {
return error;
});
});

Expand Down
9 changes: 8 additions & 1 deletion src/renderer/components/VideoSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTheme } from '@mui/material/styles';
import { PropagateLoader } from 'react-spinners';
import { useNavigate } from 'react-router-dom';
import HiddenTextField from 'renderer/common/HiddenTextField';
// import validator from 'validator';
import SnackbarPopup from 'renderer/common/SnackbarPopup';

export interface VODMetadata {
title: string;
Expand Down Expand Up @@ -37,6 +37,8 @@ const RetrieveSets = (
}

const [waiting, setWaiting] = useState(false);
const [errorMessage, setErrorMessage] = useState('');
const [errorOpen, setErrorOpen] = useState(false);

const [getSets, { loading, error, data }] = useLazyQuery(
GET_SETS_AT_STATION,
Expand Down Expand Up @@ -113,6 +115,10 @@ const RetrieveSets = (
tournamentName: data.event.tournament.name,
},
});
}).catch((err) => {
setErrorMessage("Error retrieving sets: " + err.message);
setErrorOpen(true);
setWaiting(false);
});
}
}, [data]);
Expand All @@ -127,6 +133,7 @@ const RetrieveSets = (
justifyContent: 'center',
}}
>
{SnackbarPopup(errorMessage, 'error', errorOpen, setErrorOpen)}
<Button
variant="contained"
onClick={() => {
Expand Down
14 changes: 14 additions & 0 deletions src/renderer/pages/SetsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ const SetsView = () => {
const [errorMessage, setErrorMessage] = useState('');
const [infoMessage, setInfoMessage] = useState('')
const [downloaded, setDownloaded] = useState(false)
const [enableDownload, setEnableDownload] = useState(false)

useEffect(() => {
if (checked.length == location.state.sets.length + 1) {
setEnableDownload(false)
} else {
setEnableDownload(true)
}
}, [checked])

const handleSelectAll = () => {
let newChecked = [...checked];
Expand Down Expand Up @@ -319,13 +328,15 @@ const SetsView = () => {
</List>
<Box sx={{ display: 'flex', justifyContent: 'space-around', width: '100%' }}>
<Button
disabled={!enableDownload}
variant="contained"
color="secondary"
sx={{ width: '27vw', marginTop: '20px', color: 'white' }}
onClick={() => {
setDownloaded(true)
setInfoMessage('Your VODs are being downloaded to ./downloadedVODs/' + location.state.tournamentName);
setInfoOpen(true)
setEnableDownload(false)
location.state.sets.map((set: VODMetadata) => {
if (set.download) {
console.log('Downloading set: ', set);
Expand All @@ -340,10 +351,12 @@ const SetsView = () => {
.then((res: any) => {
setSuccessMessage('Download complete: ' + set.title);
setSuccessOpen(true);
setEnableDownload(true);
})
.catch((err: any) => {
setErrorMessage('Download failed: ' + err);
setErrorOpen(true);
setEnableDownload(true);
});
}
});
Expand All @@ -361,6 +374,7 @@ const SetsView = () => {
Open VOD Folder
</Button>
<Button
disabled={!downloaded}
variant="contained"
color="secondary"
sx={{ width: '27vw', marginTop: '20px', color: 'white' }}
Expand Down

0 comments on commit a4e0e32

Please sign in to comment.