From f77a280e343f96bc133b8d0fc082af073f830741 Mon Sep 17 00:00:00 2001 From: angel Date: Sun, 25 Jan 2026 00:46:15 +0000 Subject: [PATCH] feat: add pagination to library/songs and remove listening streaks --- .env.local | 2 +- app/history/page.tsx | 5 ---- app/library/songs/page.tsx | 60 +++++++++++++++++++++++++++++++++++--- app/page.tsx | 8 ----- 4 files changed, 57 insertions(+), 18 deletions(-) diff --git a/.env.local b/.env.local index 033cab2..6b62389 100644 --- a/.env.local +++ b/.env.local @@ -1 +1 @@ -NEXT_PUBLIC_COMMIT_SHA=9427a2a +NEXT_PUBLIC_COMMIT_SHA=eb56096 diff --git a/app/history/page.tsx b/app/history/page.tsx index 14f2976..71ec7c7 100644 --- a/app/history/page.tsx +++ b/app/history/page.tsx @@ -10,7 +10,6 @@ import { Tabs, TabsContent } from '@/components/ui/tabs'; import { useAudioPlayer } from '@/app/components/AudioPlayerContext'; import { getNavidromeAPI } from '@/lib/navidrome'; import { Play, Plus, User, Disc, History, Trash2 } from 'lucide-react'; -import ListeningStreakCard from '@/app/components/ListeningStreakCard'; import { AlertDialog, AlertDialogAction, @@ -79,10 +78,6 @@ export default function HistoryPage() { return (
-
- -
-
diff --git a/app/library/songs/page.tsx b/app/library/songs/page.tsx index 2607e7d..c455988 100644 --- a/app/library/songs/page.tsx +++ b/app/library/songs/page.tsx @@ -10,13 +10,15 @@ import { Separator } from '@/components/ui/separator'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Input } from '@/components/ui/input'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; -import { Search, Play, Plus, User, Disc } from 'lucide-react'; +import { Search, Play, Plus, User, Disc, ChevronLeft, ChevronRight } from 'lucide-react'; import Loading from '@/app/components/loading'; import { getNavidromeAPI } from '@/lib/navidrome'; type SortOption = 'title' | 'artist' | 'album' | 'year' | 'duration' | 'track'; type SortDirection = 'asc' | 'desc'; +const ITEMS_PER_PAGE = 50; + export default function SongsPage() { const { getAllSongs } = useNavidrome(); const { playTrack, addToQueue, currentTrack } = useAudioPlayer(); @@ -26,6 +28,7 @@ export default function SongsPage() { const [searchQuery, setSearchQuery] = useState(''); const [sortBy, setSortBy] = useState('title'); const [sortDirection, setSortDirection] = useState('asc'); + const [currentPage, setCurrentPage] = useState(1); const api = getNavidromeAPI(); useEffect(() => { @@ -100,6 +103,7 @@ export default function SongsPage() { }); setFilteredSongs(filtered); + setCurrentPage(1); // Reset to first page when filters change }, [songs, searchQuery, sortBy, sortDirection]); const handlePlayClick = (song: Song) => { if (!api) { @@ -154,6 +158,24 @@ export default function SongsPage() { return currentTrack?.id === song.id; }; + // Pagination calculations + const totalPages = Math.ceil(filteredSongs.length / ITEMS_PER_PAGE); + const startIndex = (currentPage - 1) * ITEMS_PER_PAGE; + const endIndex = startIndex + ITEMS_PER_PAGE; + const paginatedSongs = filteredSongs.slice(startIndex, endIndex); + + const goToNextPage = () => { + if (currentPage < totalPages) { + setCurrentPage(currentPage + 1); + } + }; + + const goToPreviousPage = () => { + if (currentPage > 1) { + setCurrentPage(currentPage - 1); + } + }; + if (loading) { return ; } @@ -165,7 +187,8 @@ export default function SongsPage() {

Songs

- {filteredSongs.length} of {songs.length} songs + Showing {startIndex + 1}-{Math.min(endIndex, filteredSongs.length)} of {filteredSongs.length} songs + {searchQuery && ` (filtered from ${songs.length} total)`}

@@ -216,7 +239,7 @@ export default function SongsPage() {
) : (
- {filteredSongs.map((song, index) => ( + {paginatedSongs.map((song, index) => (
) : ( <> - {index + 1} + {startIndex + index + 1} )} @@ -298,6 +321,35 @@ export default function SongsPage() {
)} + + {/* Pagination Controls */} + {filteredSongs.length > ITEMS_PER_PAGE && ( +
+

+ Page {currentPage} of {totalPages} +

+
+ + +
+
+ )}
); diff --git a/app/page.tsx b/app/page.tsx index 7647683..212ad6d 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -14,7 +14,6 @@ import { SongRecommendations } from './components/SongRecommendations'; import { Skeleton } from '@/components/ui/skeleton'; import { useIsMobile } from '@/hooks/use-mobile'; import { UserProfile } from './components/UserProfile'; -import CompactListeningStreak from './components/CompactListeningStreak'; type TimeOfDay = 'morning' | 'afternoon' | 'evening'; @@ -205,17 +204,10 @@ function MusicPageContent() { return (
- {/* Connection status (offline indicator) */} - {/* Song Recommendations Section */}
- - {/* Listening Streak Section - Only shown when 3+ days streak */} -
- -
<>