Skip to content

Commit

Permalink
add error toast
Browse files Browse the repository at this point in the history
  • Loading branch information
ra0x3 committed Dec 15, 2024
1 parent a57f88f commit cc24a9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions www/libx/src/services/Download.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ function useDownload() {
payload: true,
});

dispatch({
type: Action.SET_DOWNLOAD_ERROR,
payload: null,
});

const filename = `libx-export-${v4()}.csv`;

try {
Expand Down
9 changes: 5 additions & 4 deletions www/libx/src/views/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function Index() {

const subtitle = useSelector((state: State) => state.content.subtitle);
const loading = useSelector((state: State) => state.download.loading);
const error = useSelector((state: State) => state.download.error);
const downloadURI = useSelector((state: State) => state.download.downloadURI);

const onClick = () => {
Expand Down Expand Up @@ -55,18 +56,18 @@ function Index() {
if (loading) {
toast('Downloading your library.', {
autoClose: 10000,
progressStyle: {
backgroundColor: '#f88895',
},
});
}

if (downloadURI) {
toast('Download finished!', {
autoClose: 10000,
progressStyle: { backgroundColor: '#f88895' },
});
}

if (error) {
toast.error(`Failed to download library.`);
}
}, [loading, downloadURI]);

return (
Expand Down

0 comments on commit cc24a9f

Please sign in to comment.