Skip to content

Commit

Permalink
Hide album loader on error
Browse files Browse the repository at this point in the history
  • Loading branch information
juffalow committed Sep 17, 2024
1 parent b2ddb3d commit 50b01d2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions frontend/src/pages/Album.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const Album: React.FC = () => {
const params = useParams();
const location = useLocation();
const [ album, setAlbum ] = useState<Album | undefined>(location.state?.album);
const [ files, setFiles ] = useState([] as Array<Media>);
const [ hasError, setHasError ] = useState(false);
const {
files: uploadedFiles
Expand All @@ -27,7 +26,7 @@ const Album: React.FC = () => {
}

getAlbum(params.id as string)
.then((album) => setFiles(album.media))
.then(album => { setAlbum(album); return album; })
.catch(() => setHasError(true));
}, []);

Expand All @@ -41,21 +40,25 @@ const Album: React.FC = () => {
}
{
hasError ? (
<Alert variant="danger">
Tento album už nie je dostupný.
</Alert>
<Row>
<Col md={{ span: 6, offset: 3 }}>
<Alert variant="danger" className="text-center">
Tento album už nie je dostupný.
</Alert>
</Col>
</Row>
) : null
}
{
uploadedFiles.length === 0 && files.length === 0? (
typeof album === 'undefined' && hasError === false ? (
<GalleryLoader />
) : null
}
{
files.length > 0 ? (
typeof album !== 'undefined' && 'media' in album && album.media.length > 0 ? (
<Row>
<Col>
<GalleryNew files={files} />
<GalleryNew files={album.media} />
</Col>
</Row>
) : null
Expand Down

0 comments on commit 50b01d2

Please sign in to comment.