@@ -547,6 +547,51 @@ export default function RecentlyPlayed({
547547 showPlaylists ,
548548 ] ) ;
549549
550+ const mainContent = ( ) => {
551+ if ( loading ) {
552+ return (
553+ < View style = { styles . loadingContainer } >
554+ < ActivityIndicator size = "large" color = "#FFFFFF" />
555+ < Text style = { styles . loadingText } > Loading playlist...</ Text >
556+ </ View >
557+ ) ;
558+ }
559+
560+ if ( error ) {
561+ return (
562+ < View style = { styles . errorContainer } >
563+ < Text style = { styles . errorText } > { error } </ Text >
564+ < TouchableOpacity onPress = { handleRefresh } style = { styles . retryButton } >
565+ < Text style = { styles . retryButtonText } > Retry</ Text >
566+ </ TouchableOpacity >
567+ </ View >
568+ ) ;
569+ }
570+
571+ if ( ! currentShow || currentShow === DEFAULT_NAME ) {
572+ return (
573+ < View style = { styles . emptyContainer } >
574+ < Text style = { styles . emptyText } > No playlists found</ Text >
575+ </ View >
576+ ) ;
577+ }
578+
579+ if (
580+ showPlaylists . length > 0 &&
581+ ( showPlaylists [ 0 ] . songs . length > 0 || showPlaylists . length > 1 )
582+ ) {
583+ return < > { renderPlaylistContent ( ) } </ > ;
584+ }
585+
586+ return (
587+ < View style = { styles . emptyContainer } >
588+ < Text style = { styles . emptyText } >
589+ No playlist found for { currentShow }
590+ </ Text >
591+ </ View >
592+ ) ;
593+ } ;
594+
550595 return (
551596 < >
552597 { /* Content */ }
@@ -579,37 +624,7 @@ export default function RecentlyPlayed({
579624 < Text style = { styles . currentShowSubtitle } > Now Playing</ Text >
580625 </ View >
581626 ) }
582-
583- { loading ? (
584- < View style = { styles . loadingContainer } >
585- < ActivityIndicator size = "large" color = "#FFFFFF" />
586- < Text style = { styles . loadingText } > Loading playlist...</ Text >
587- </ View >
588- ) : error ? (
589- < View style = { styles . errorContainer } >
590- < Text style = { styles . errorText } > { error } </ Text >
591- < TouchableOpacity
592- onPress = { handleRefresh }
593- style = { styles . retryButton }
594- >
595- < Text style = { styles . retryButtonText } > Retry</ Text >
596- </ TouchableOpacity >
597- </ View >
598- ) : ! currentShow || currentShow === DEFAULT_NAME ? (
599- < View style = { styles . emptyContainer } >
600- < Text style = { styles . emptyText } > No playlists found</ Text >
601- </ View >
602- ) : showPlaylists . length > 0 &&
603- ( showPlaylists [ 0 ] . songs . length > 0 || showPlaylists . length > 1 ) ? (
604- < > { renderPlaylistContent ( ) } </ >
605- ) : (
606- < View style = { styles . emptyContainer } >
607- < Text style = { styles . emptyText } >
608- No playlist found for { currentShow }
609- </ Text >
610- </ View >
611- ) }
612-
627+ { mainContent ( ) }
613628 { /* Bottom padding for gesture area */ }
614629 < View style = { styles . bottomPadding } />
615630 </ ScrollView >
0 commit comments