88 ScrollView ,
99 Image ,
1010} from 'react-native' ;
11+ import RNFS from 'react-native-fs' ;
12+ import { TMDBService } from '../services/TMDBService' ;
1113import Svg , { Circle } from 'react-native-svg' ;
1214import Icon from 'react-native-vector-icons/MaterialIcons' ;
1315import {
@@ -20,6 +22,62 @@ import {
2022import { downloadService } from '../services' ;
2123import { COLORS } from '../utils/constants' ;
2224
25+ // Helper component: DownloadThumbnail - resolves local file or TMDB fallback
26+ const DownloadThumbnail : React . FC < { download : DownloadItem } > = ( { download } ) => {
27+ const [ uri , setUri ] = useState < string | null > ( null ) ;
28+
29+ useEffect ( ( ) => {
30+ let mounted = true ;
31+ const tmdb = new TMDBService ( ) ;
32+
33+ const resolve = async ( ) => {
34+ try {
35+ if ( download . thumbnailPath ) {
36+ const exists = await RNFS . exists ( download . thumbnailPath ) ;
37+ if ( exists && mounted ) {
38+ setUri ( `file://${ download . thumbnailPath } ` ) ;
39+ return ;
40+ }
41+ }
42+
43+ // fallback to TMDB poster or backdrop
44+ if ( download . posterPath ) {
45+ const remote = tmdb . getImageUrl ( download . posterPath ) ;
46+ if ( mounted ) setUri ( remote ) ;
47+ return ;
48+ }
49+
50+ if ( download . backdropPath ) {
51+ const remote = tmdb . getImageUrl ( download . backdropPath ) ;
52+ if ( mounted ) setUri ( remote ) ;
53+ return ;
54+ }
55+
56+ setUri ( null ) ;
57+ } catch ( error ) {
58+ console . warn ( 'Failed to resolve download thumbnail:' , error ) ;
59+ if ( mounted ) setUri ( null ) ;
60+ }
61+ } ;
62+
63+ resolve ( ) ;
64+
65+ return ( ) => { mounted = false ; } ;
66+ } , [ download ] ) ;
67+
68+ if ( ! uri ) {
69+ return (
70+ < View style = { styles . placeholderImage } >
71+ < Icon name = "movie" size = { 32 } color = { COLORS . NETFLIX_GRAY } />
72+ </ View >
73+ ) ;
74+ }
75+
76+ return (
77+ < Image source = { { uri } } style = { styles . thumbnail } resizeMode = "cover" />
78+ ) ;
79+ } ;
80+
2381interface CircularProgressProps {
2482 size : number ;
2583 progress : number ;
@@ -613,17 +671,7 @@ export const DownloadsList: React.FC<DownloadsListProps> = ({
613671 activeOpacity = { 0.7 }
614672 >
615673 < View style = { styles . downloadImage } >
616- { download . thumbnailPath ? (
617- < Image
618- source = { { uri : `file://${ download . thumbnailPath } ` } }
619- style = { styles . thumbnail }
620- resizeMode = "cover"
621- />
622- ) : (
623- < View style = { styles . placeholderImage } >
624- < Icon name = "movie" size = { 32 } color = { COLORS . NETFLIX_GRAY } />
625- </ View >
626- ) }
674+ < DownloadThumbnail download = { download } />
627675
628676 { download . status === DownloadStatus . DOWNLOADING && (
629677 < View style = { styles . progressOverlay } >
0 commit comments