From 92e86527c31c1fe6f697754e5174d2494c9f5fa8 Mon Sep 17 00:00:00 2001 From: Antti Kettunen Date: Thu, 14 May 2026 17:27:48 +0300 Subject: [PATCH] refactor(webui): simplify stats artist detail handoff - remove the stats page timeout and library pre-navigation hack - hand artist detail opening directly to the legacy shell bridge - add a route test covering the direct artist navigation bridge call --- webui/src/routes/stats/-route.test.tsx | 11 ++++++++ webui/src/routes/stats/-ui/stats-page.tsx | 31 ++++++----------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/webui/src/routes/stats/-route.test.tsx b/webui/src/routes/stats/-route.test.tsx index 604e8493..189ca154 100644 --- a/webui/src/routes/stats/-route.test.tsx +++ b/webui/src/routes/stats/-route.test.tsx @@ -114,6 +114,17 @@ describe('stats route', () => { await waitFor(() => expect(history.location.search).toContain('range=30d')); }); + it('hands artist detail navigation directly to the shell bridge', async () => { + renderStatsRoute(); + + fireEvent.click(await screen.findByRole('button', { name: 'Artist A' })); + + expect(window.SoulSyncWebShellBridge?.navigateToArtistDetail).toHaveBeenCalledWith( + 7, + 'Artist A', + ); + }); + it('redirects back home when the page is not allowed', async () => { window.SoulSyncWebShellBridge = createShellBridge({ isPageAllowed: vi.fn((pageId) => pageId !== 'stats'), diff --git a/webui/src/routes/stats/-ui/stats-page.tsx b/webui/src/routes/stats/-ui/stats-page.tsx index a16c48de..5a9f4c94 100644 --- a/webui/src/routes/stats/-ui/stats-page.tsx +++ b/webui/src/routes/stats/-ui/stats-page.tsx @@ -135,6 +135,10 @@ export function StatsPage() { }); }; + const openArtistDetail = (artistId: string | number, artistName: string) => { + bridge.navigateToArtistDetail(artistId, artistName); + }; + return (
@@ -214,31 +218,23 @@ export function StatsPage() { - void openArtistDetail(bridge, artistId, artistName) - } + onArtistSelect={(artistId, artistName) => openArtistDetail(artistId, artistName)} /> - void openArtistDetail(bridge, artistId, artistName) - } + onArtistSelect={(artistId, artistName) => openArtistDetail(artistId, artistName)} /> - void openArtistDetail(bridge, artistId, artistName) - } + onArtistSelect={(artistId, artistName) => openArtistDetail(artistId, artistName)} /> - void openArtistDetail(bridge, artistId, artistName) - } + onArtistSelect={(artistId, artistName) => openArtistDetail(artistId, artistName)} onPlay={(track) => playStatsTrack(bridge, track)} /> @@ -877,17 +873,6 @@ function EmptyListState({ message }: { message: string }) { return
{message}
; } -async function openArtistDetail( - bridge: ShellBridge, - artistId: string | number, - artistName: string, -) { - await window.SoulSyncWebRouter?.navigateToPage('library'); - window.setTimeout(() => { - bridge.navigateToArtistDetail(artistId, artistName); - }, 300); -} - async function playStatsTrack( bridge: ShellBridge, track: { title: string; artist: string; album: string },