From 48ccd1c0b5754cfc70d3e7159c1c813a109bccc1 Mon Sep 17 00:00:00 2001 From: Martin Reitschmied Date: Sun, 5 Apr 2026 15:50:19 +0200 Subject: [PATCH] fix: prevent Library page crash when navigating to TV shows from dashboard The dashboard TV Shows stat card linked to /library?tab=tvshows, but the valid MediaType key is 'tv'. The invalid tab value caused a crash when accessing MEDIA_TYPE_CONFIG with an unknown key. Fixed the link and added validation so unrecognized tab params fall back to 'movies'. Co-Authored-By: Paperclip --- inertia/pages/dashboard.tsx | 2 +- inertia/pages/library/index.tsx | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/inertia/pages/dashboard.tsx b/inertia/pages/dashboard.tsx index 0357f02..65a36dd 100644 --- a/inertia/pages/dashboard.tsx +++ b/inertia/pages/dashboard.tsx @@ -399,7 +399,7 @@ export default function Dashboard({ value={stats.tvShows} icon={Tv01Icon} subtitle={`${stats.episodes.toLocaleString()} episodes`} - href="/library?tab=tvshows" + href="/library?tab=tv" /> ('all') const [sortBy, setSortBy] = useState('name') - // Read initial tab from URL - const initialTab = - typeof window !== 'undefined' - ? (new URLSearchParams(window.location.search).get('tab') as MediaType) || 'movies' + // Read initial tab from URL (validate against known types to prevent crashes) + const initialTab = (() => { + if (typeof window === 'undefined') return 'movies' as MediaType + const urlTab = new URLSearchParams(window.location.search).get('tab') + return urlTab && MEDIA_TYPE_ORDER.includes(urlTab as MediaType) + ? (urlTab as MediaType) : 'movies' + })() const [activeTab, setActiveTabState] = useState(initialTab) // Sync active tab to URL and reset filters