diff --git a/react_frontend/src/api/people.ts b/react_frontend/src/api/people.ts index d9bbf19..af98885 100644 --- a/react_frontend/src/api/people.ts +++ b/react_frontend/src/api/people.ts @@ -23,6 +23,7 @@ export interface TmdbFilmographyResponse { export interface TmdbPersonPreview { tmdb_id: number; + local_id: number | null; name: string; biography: string | null; birthday: string | null; diff --git a/react_frontend/src/pages/PersonDetailsPage.tsx b/react_frontend/src/pages/PersonDetailsPage.tsx index 2857286..b07d329 100644 --- a/react_frontend/src/pages/PersonDetailsPage.tsx +++ b/react_frontend/src/pages/PersonDetailsPage.tsx @@ -1,5 +1,5 @@ import { useParams, useNavigate, useLocation } from 'react-router-dom'; -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { usePerson, usePersonTmdbFilmography, @@ -121,6 +121,13 @@ function TmdbPersonView({ tmdbId }: { tmdbId: number }) { const libraryMap = useLibraryStore((s) => s.entries); const libraryLoaded = useLibraryStore((s) => s.isLoaded); + // If person already exists in local DB, redirect to their local page + useEffect(() => { + if (preview?.local_id) { + navigate(`/people/${preview.local_id}`, { replace: true }); + } + }, [preview?.local_id, navigate]); + if (isError) { return (
@@ -137,6 +144,11 @@ function TmdbPersonView({ tmdbId }: { tmdbId: number }) { return ; } + // Redirecting to local page, show skeleton while navigating + if (preview.local_id) { + return ; + } + const profileUrl = preview.profile_path ? `${TMDB_IMG}/w300${preview.profile_path}` : undefined;