From d832dfb253a16b8d74654197e0cd4687aaf15b07 Mon Sep 17 00:00:00 2001 From: Psychotoxical Date: Wed, 8 Apr 2026 15:37:12 +0200 Subject: [PATCH] fix(statistics): remove Top Rated Songs/Artists sections The implementation was unreliable (depended on starred songs + session-only overrides) so the sections are removed entirely. All PR#130 rating logic (StarRating, setRating API calls, userRatingOverrides) is untouched. Co-Authored-By: Claude Sonnet 4.6 --- src/pages/Statistics.tsx | 97 ++-------------------------------------- 1 file changed, 3 insertions(+), 94 deletions(-) diff --git a/src/pages/Statistics.tsx b/src/pages/Statistics.tsx index f8a941f3..9627d0c6 100644 --- a/src/pages/Statistics.tsx +++ b/src/pages/Statistics.tsx @@ -1,10 +1,9 @@ -import React, { useEffect, useMemo, useState } from 'react'; -import { getAlbumList, getArtists, getGenres, getRandomSongs, getStarred, SubsonicAlbum, SubsonicArtist, SubsonicGenre, SubsonicSong } from '../api/subsonic'; +import React, { useEffect, useState } from 'react'; +import { getAlbumList, getArtists, getGenres, getRandomSongs, SubsonicAlbum, SubsonicGenre } from '../api/subsonic'; import AlbumRow from '../components/AlbumRow'; import { useTranslation } from 'react-i18next'; import { useAuthStore } from '../store/authStore'; import { useNavigate } from 'react-router-dom'; -import { usePlayerStore } from '../store/playerStore'; import { lastfmIsConfigured, lastfmGetTopArtists, lastfmGetTopAlbums, lastfmGetTopTracks, lastfmGetRecentTracks, LastfmPeriod, LastfmTopArtist, LastfmTopAlbum, LastfmTopTrack, LastfmRecentTrack } from '../api/lastfm'; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -40,27 +39,6 @@ export default function Statistics() { const [recent, setRecent] = useState([]); const [frequent, setFrequent] = useState([]); const [highest, setHighest] = useState([]); - const [starredSongs, setStarredSongs] = useState([]); - const [topArtists, setTopArtists] = useState([]); - const userRatingOverrides = usePlayerStore(s => s.userRatingOverrides); - const queue = usePlayerStore(s => s.queue); - const currentTrack = usePlayerStore(s => s.currentTrack); - - const topSongs = useMemo(() => { - const map = new Map(starredSongs.map(s => [s.id, { ...s, userRating: userRatingOverrides[s.id] ?? s.userRating }])); - // Songs not yet in starredSongs but rated via override (e.g. from queue or currentTrack) - const candidates = currentTrack ? [currentTrack, ...queue] : queue; - for (const t of candidates) { - const r = userRatingOverrides[t.id]; - if (r && !map.has(t.id)) { - map.set(t.id, { id: t.id, title: t.title, artist: t.artist, album: t.album, albumId: t.albumId, userRating: r } as SubsonicSong); - } - } - return [...map.values()] - .filter(s => (s.userRating ?? 0) > 0) - .sort((a, b) => (b.userRating ?? 0) - (a.userRating ?? 0)) - .slice(0, 10); - }, [starredSongs, userRatingOverrides, queue, currentTrack]); const [artistCount, setArtistCount] = useState(null); const [totalSongs, setTotalSongs] = useState(null); const [totalAlbums, setTotalAlbums] = useState(null); @@ -87,8 +65,7 @@ export default function Statistics() { getAlbumList('highest', 12).catch(() => []), getArtists().catch(() => []), getGenres().catch(() => []), - getStarred().catch(() => ({ albums: [], artists: [], songs: [] })), - ]).then(([rc, fr, hi, a, g, starred]) => { + ]).then(([rc, fr, hi, a, g]) => { setRecent(rc); setFrequent(fr); setHighest(hi); @@ -97,13 +74,6 @@ export default function Statistics() { setTotalAlbums(g.reduce((acc: number, genre: SubsonicGenre) => acc + genre.albumCount, 0)); const sorted = [...g].sort((a, b) => b.songCount - a.songCount); setGenres(sorted); - setStarredSongs(starred.songs); - setTopArtists( - [...starred.artists] - .filter(a => (a.userRating ?? 0) > 0) - .sort((a, b) => (b.userRating ?? 0) - (a.userRating ?? 0)) - .slice(0, 10), - ); setLoading(false); }).catch(() => setLoading(false)); }, [musicLibraryFilterVersion]); @@ -317,67 +287,6 @@ export default function Statistics() { showRating /> - {/* Top Rated Songs + Artists */} -
-
-

- {t('statistics.topRatedSongs')} -

- {topSongs.length === 0 ? ( -

{t('statistics.noRatedSongs')}

- ) : ( -
    - {topSongs.map((song, i) => ( -
  1. song.albumId && navigate(`/album/${song.albumId}`)}> - - {i + 1} - -
    -
    {song.title}
    -
    {song.artist}
    -
    - - {'★'.repeat(song.userRating!)}{'☆'.repeat(5 - song.userRating!)} - -
  2. - ))} -
- )} -
- -
-

- {t('statistics.topRatedArtists')} -

- {topArtists.length === 0 ? ( -

{t('statistics.noRatedArtists')}

- ) : ( -
    - {topArtists.map((artist, i) => ( -
  1. navigate(`/artist/${artist.id}`)}> - - {i + 1} - -
    -
    {artist.name}
    - {(artist.albumCount ?? 0) > 0 && ( -
    - {t('artistDetail.albumCount_other', { count: artist.albumCount })} -
    - )} -
    - - {'★'.repeat(artist.userRating!)}{'☆'.repeat(5 - artist.userRating!)} - -
  2. - ))} -
- )} -
-
- {/* Last.fm Stats */} {lastfmIsConfigured() && (