fix(frontend): redirect to local person page if already in DB
- PersonDetailsPage (TMDB mode) redirects to /people/:localId when local_id is present - "Add to Library" button only shown for people not in local DB - Shows skeleton during redirect to avoid flash of preview content Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
1 parent
507cdbcff7
commit
b3002a329d
2 files changed
+14
-1
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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 (
|
||||
<div className="flex flex-col items-center justify-center gap-3 py-20">
|
||||
@@ -137,6 +144,11 @@ function TmdbPersonView({ tmdbId }: { tmdbId: number }) {
|
||||
return <PersonSkeleton />;
|
||||
}
|
||||
|
||||
// Redirecting to local page, show skeleton while navigating
|
||||
if (preview.local_id) {
|
||||
return <PersonSkeleton />;
|
||||
}
|
||||
|
||||
const profileUrl = preview.profile_path
|
||||
? `${TMDB_IMG}/w300${preview.profile_path}`
|
||||
: undefined;
|
||||
|
||||
Reference in new issue
Block a user