From 1e632f813c6a141e7ca91e7daefd63a27538a3be Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 17 Jul 2025 18:08:28 -0500 Subject: [PATCH] Signed-off-by: Matt Bruce --- src/features/TopPlayed/Top100.tsx | 174 ++++++++++++++++-------------- 1 file changed, 95 insertions(+), 79 deletions(-) diff --git a/src/features/TopPlayed/Top100.tsx b/src/features/TopPlayed/Top100.tsx index 7ee4f71..92552d8 100644 --- a/src/features/TopPlayed/Top100.tsx +++ b/src/features/TopPlayed/Top100.tsx @@ -1,11 +1,9 @@ import React from 'react'; -import { IonHeader, IonToolbar, IonTitle, IonChip, IonIcon } from '@ionic/react'; -import { trophy } from 'ionicons/icons'; -import { InfiniteScrollList } from '../../components/common'; +import { IonHeader, IonToolbar, IonTitle, IonChip, IonButton } from '@ionic/react'; import { useTopPlayed } from '../../hooks'; import { useAppSelector } from '../../redux'; import { selectTopPlayed } from '../../redux'; -import type { TopPlayed, Song } from '../../types'; +import type { TopPlayed } from '../../types'; const Top100: React.FC = () => { console.log('Top100 component - RENDERING START'); @@ -13,8 +11,6 @@ const Top100: React.FC = () => { const { topPlayedItems, loadMore, - handleAddToQueue, - handleToggleFavorite, } = useTopPlayed(); const topPlayed = useAppSelector(selectTopPlayed); @@ -22,81 +18,73 @@ const Top100: React.FC = () => { console.log('Top100 component - Redux data:', { topPlayedCount, topPlayedItems: topPlayedItems.length }); - // Mock data for testing + // Mock data for testing - these are artist/title combinations, not individual songs const mockTopPlayedItems: TopPlayed[] = [ { key: 'mock-1', - title: 'Bohemian Rhapsody', - artist: 'Queen', - count: 156 + title: 'CAN\'T STOP THE FEELING', + artist: 'Justin Timberlake', + count: 63 }, { key: 'mock-2', - title: 'Sweet Caroline', + title: 'SWEET CAROLINE', artist: 'Neil Diamond', - count: 142 + count: 58 }, { key: 'mock-3', - title: 'Don\'t Stop Believin\'', + title: 'DON\'T STOP BELIEVIN\'', artist: 'Journey', - count: 128 + count: 52 }, { key: 'mock-4', - title: 'Livin\' on a Prayer', + title: 'LIVIN\' ON A PRAYER', artist: 'Bon Jovi', - count: 115 + count: 47 }, { key: 'mock-5', - title: 'Wonderwall', + title: 'WONDERWALL', artist: 'Oasis', - count: 98 + count: 41 }, { key: 'mock-6', - title: 'Hotel California', + title: 'HOTEL CALIFORNIA', artist: 'Eagles', - count: 87 + count: 38 }, { key: 'mock-7', - title: 'Stairway to Heaven', + title: 'STAIRWAY TO HEAVEN', artist: 'Led Zeppelin', - count: 76 + count: 35 }, { key: 'mock-8', - title: 'Imagine', + title: 'IMAGINE', artist: 'John Lennon', - count: 65 + count: 32 }, { key: 'mock-9', - title: 'Hey Jude', + title: 'HEY JUDE', artist: 'The Beatles', - count: 54 + count: 29 }, { key: 'mock-10', - title: 'Yesterday', + title: 'YESTERDAY', artist: 'The Beatles', - count: 43 + count: 26 } ]; - // Convert TopPlayed items to Song format for consistent UI - const songItems: Song[] = mockTopPlayedItems.map((item: TopPlayed) => ({ - ...item, - path: '', // TopPlayed doesn't have path - disabled: false, - favorite: false, - })); - // Use mock data for now - const displayItems = songItems; - const displayCount = songItems.length; + const displayItems = mockTopPlayedItems; + const displayCount = displayItems.length; const displayHasMore = false; // No more mock data to load console.log('Top100 component - Mock data:', { @@ -108,23 +96,6 @@ const Top100: React.FC = () => { console.log('Top100 component - About to render JSX'); - // Wrapper functions to handle type conversion - const handleAddToQueueWrapper = (song: Song) => { - console.log('Top100 component - Add to Queue clicked:', song); - const topPlayedItem = mockTopPlayedItems.find(item => item.key === song.key); - if (topPlayedItem) { - handleAddToQueue(topPlayedItem); - } - }; - - const handleToggleFavoriteWrapper = (song: Song) => { - console.log('Top100 component - Remove clicked:', song); - const topPlayedItem = mockTopPlayedItems.find(item => item.key === song.key); - if (topPlayedItem) { - handleToggleFavorite(topPlayedItem); - } - }; - return ( <> @@ -138,33 +109,78 @@ const Top100: React.FC = () => { - ( -
-
- - #{index + 1} +
+ {/* Debug info */} +
+ Top played items loaded: {displayCount} (Mock Data) +
+ + {/* Content */} +
+ {displayCount === 0 ? ( +
+
+ + + +
+

Loading top played songs...

+

Please wait while top played data is being loaded

- - {item.count} play{item.count !== 1 ? 's' : ''} - + ) : displayItems.length === 0 ? ( +
+
+ + + +
+

No top played songs

+

Play some songs to see the top played list

+
+ ) : ( +
+ {displayItems.map((item, index) => ( +
+
+ + {index + 1}) + +
+
+
+
+ {item.title} ({item.count}) +
+
+ {item.artist} +
+
+
+ ))} + + {/* Load more button */} + {displayHasMore && ( +
+ + Load More + +
+ )} +
+ )} +
+ + {/* Stats */} + {displayItems.length > 0 && ( +
+ Showing {displayItems.length} item{displayItems.length !== 1 ? 's' : ''} + {displayHasMore && ` • Click "Load More" to see more`}
)} - /> +
); };