From 9d2776738912d07dc44ef63bc185ec4929c4421c Mon Sep 17 00:00:00 2001 From: John Corser Date: Thu, 2 Jan 2025 14:21:13 -0500 Subject: [PATCH] handle no movies/shows watched --- src/components/pages/OldestMoviePage.tsx | 17 +++++++++++++++++ src/components/pages/OldestShowPage.tsx | 17 ++++++++++++++++- src/lib/cache.ts | 17 ++++++++++------- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/components/pages/OldestMoviePage.tsx b/src/components/pages/OldestMoviePage.tsx index 8efa1b2..079babf 100644 --- a/src/components/pages/OldestMoviePage.tsx +++ b/src/components/pages/OldestMoviePage.tsx @@ -71,6 +71,23 @@ export default function OldestMoviePage() { textShadow: "0 0 30px rgba(255, 215, 0, 0.3)", }); + if (!movie?.id) { + return ( + <> + <>No movies watched.{" "} + + + ); + } + return ( + <>No shows watched.{" "} + + + ); + } return ( = {}; export const setCacheValue = (key: string, value: string) => { + const userConfigCacheKeys = [ + JELLYFIN_SERVER_URL_CACHE_KEY, + JELLYFIN_AUTH_TOKEN_CACHE_KEY, + JELLYFIN_USERNAME_CACHE_KEY, + JELLYFIN_PASSWORD_CACHE_KEY, + ]; try { localCache[key] = value; localStorage.setItem(key, value); + if (userConfigCacheKeys.includes(key)) { + localStorage.removeItem(JELLYFIN_CURRENT_USER_CACHE_KEY); + } } catch (error) { console.warn(`Error setting cache value for key ${key}:`, error); - const necessaryCacheKeys = [ - JELLYFIN_SERVER_URL_CACHE_KEY, - JELLYFIN_AUTH_TOKEN_CACHE_KEY, - JELLYFIN_USERNAME_CACHE_KEY, - JELLYFIN_PASSWORD_CACHE_KEY, - ]; - if (necessaryCacheKeys.includes(key)) { + if (userConfigCacheKeys.includes(key)) { throw new Error(`Error setting cache value for key ${key}: ${error}`); } }