Skip to content

Commit

Permalink
handle no movies/shows watched
Browse files Browse the repository at this point in the history
  • Loading branch information
John Corser committed Jan 2, 2025
1 parent 6e8b99f commit 9d27767
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
17 changes: 17 additions & 0 deletions src/components/pages/OldestMoviePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.</>{" "}
<Button
size={"4"}
style={{ width: "100%" }}
onClick={() => {
navigate("/shows");
}}
>
Review Shows
</Button>
</>
);
}

return (
<Box
style={{ backgroundColor: "var(--yellow-8)" }}
Expand Down
17 changes: 16 additions & 1 deletion src/components/pages/OldestShowPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,22 @@ export default function OldestShowPage() {
WebkitTextFillColor: "transparent",
textShadow: "0 0 30px rgba(255, 215, 0, 0.3)",
});

if (!show?.item?.id) {
return (
<>
<>No shows watched.</>{" "}
<Button
size={"4"}
style={{ width: "100%" }}
onClick={() => {
navigate("/actors");
}}
>
Review Favorite Actors
</Button>
</>
);
}
return (
<Box
style={{ backgroundColor: "var(--yellow-8)" }}
Expand Down
17 changes: 10 additions & 7 deletions src/lib/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ export const JELLYFIN_CURRENT_USER_CACHE_KEY = "jellyfinwrapped_current_user";
export const JELLYFIN_HIDDEN_ITEMS = "jellyfinwrapped_hidden_items";
const localCache: Record<string, string> = {};
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}`);
}
}
Expand Down

0 comments on commit 9d27767

Please sign in to comment.