From 2bd9cf99505dcf700e8cc52a7b506acf9661cc6b Mon Sep 17 00:00:00 2001 From: Lei Nelissen Date: Wed, 12 Jul 2023 23:28:00 +0200 Subject: [PATCH] fix: show error messages when tracks fail to download --- src/components/DownloadManager.ts | 3 +- src/screens/Downloads/index.tsx | 66 ++++++++++++++++++------------- src/store/downloads/actions.ts | 4 +- src/store/downloads/index.ts | 16 ++++++++ src/store/downloads/types.ts | 3 +- src/utility/MimeTypes.ts | 1 + 6 files changed, 61 insertions(+), 32 deletions(-) diff --git a/src/components/DownloadManager.ts b/src/components/DownloadManager.ts index 491938f..3b178c0 100644 --- a/src/components/DownloadManager.ts +++ b/src/components/DownloadManager.ts @@ -55,7 +55,7 @@ function DownloadManager () { }, [queued, dispatch, activeDownloads]); useEffect(() => { - // GUARD: We only run this functino once + // GUARD: We only run this function once if (hasRehydratedOrphans) { return; } @@ -99,7 +99,6 @@ function DownloadManager () { setHasRehydratedOrphans(true); }, [rehydrated, ids, hasRehydratedOrphans, dispatch]); - return null; } diff --git a/src/screens/Downloads/index.tsx b/src/screens/Downloads/index.tsx index b868351..1ec912b 100644 --- a/src/screens/Downloads/index.tsx +++ b/src/screens/Downloads/index.tsx @@ -17,6 +17,7 @@ import FastImage from 'react-native-fast-image'; import { useGetImage } from '@/utility/JellyfinApi'; import { ShadowWrapper } from '@/components/Shadow'; import { SafeFlatList } from '@/components/SafeNavigatorView'; +import { THEME_COLOR } from '@/CONSTANTS'; const DownloadedTrack = styled.View` flex: 1 0 auto; @@ -32,6 +33,10 @@ const AlbumImage = styled(FastImage)` border-radius: 4px; `; +const ErrorWrapper = styled.View` + padding: 2px 16px 8px 16px; +`; + function Downloads() { const defaultStyles = useDefaultStyles(); const dispatch = useAppDispatch(); @@ -106,35 +111,42 @@ function Downloads() { ), [totalDownloadSize, defaultStyles, failedIds.length, handleRetryFailed, handleDeleteAllTracks, ids.length]); const renderItem = useCallback['renderItem']>>(({ item }) => ( - - - - - - - - - {tracks[item]?.Name} - - - {tracks[item]?.AlbumArtist} {tracks[item]?.Album ? `— ${tracks[item]?.Album}` : ''} - - - - {entities[item]?.isComplete && entities[item]?.size ? ( - - {formatBytes(entities[item]?.size || 0)} - - ) : null} + <> + - + + + -