Normalize to double quotes across all files with Prettier
This commit is contained in:
1 parent
73bff72cec
commit
a5659cf4c8
190 files changed
+9523
-8859
No files matched your search
@@ -1,22 +1,22 @@
|
||||
import { useState, useCallback, useRef, useEffect, useMemo } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { usePopularPeople, useTmdbSearchPeople } from '@/hooks/useTmdb';
|
||||
import { useLocalPeopleInfinite } from '@/hooks/usePeople';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { Search, Heart } from 'lucide-react';
|
||||
import { getProfileUrl } from '@/lib/media-utils';
|
||||
import { useState, useCallback, useRef, useEffect, useMemo } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { usePopularPeople, useTmdbSearchPeople } from "@/hooks/useTmdb";
|
||||
import { useLocalPeopleInfinite } from "@/hooks/usePeople";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { Search, Heart } from "lucide-react";
|
||||
import { getProfileUrl } from "@/lib/media-utils";
|
||||
|
||||
type PeopleFilter = 'all' | 'favorite';
|
||||
type PeopleFilter = "all" | "favorite";
|
||||
|
||||
export function PeoplePage() {
|
||||
const [search, setSearch] = useState('');
|
||||
const [debouncedSearch, setDebouncedSearch] = useState('');
|
||||
const [filter, setFilter] = useState<PeopleFilter>('all');
|
||||
const [search, setSearch] = useState("");
|
||||
const [debouncedSearch, setDebouncedSearch] = useState("");
|
||||
const [filter, setFilter] = useState<PeopleFilter>("all");
|
||||
const [localOnly, setLocalOnly] = useState(false);
|
||||
|
||||
// Debounce search input
|
||||
@@ -28,16 +28,21 @@ export function PeoplePage() {
|
||||
const isSearching = debouncedSearch.length > 0;
|
||||
|
||||
const popularQuery = usePopularPeople();
|
||||
const tmdbSearchQuery = useTmdbSearchPeople(localOnly ? '' : debouncedSearch);
|
||||
const tmdbSearchQuery = useTmdbSearchPeople(localOnly ? "" : debouncedSearch);
|
||||
|
||||
// Paginated local people (handles both search and browse)
|
||||
const localPeopleQuery = useLocalPeopleInfinite(
|
||||
localOnly ? debouncedSearch : '',
|
||||
localOnly ? debouncedSearch : "",
|
||||
localOnly,
|
||||
);
|
||||
|
||||
// For TMDB mode, use infinite scroll queries
|
||||
const activeQuery = isSearching && !localOnly ? tmdbSearchQuery : !localOnly ? popularQuery : null;
|
||||
const activeQuery =
|
||||
isSearching && !localOnly
|
||||
? tmdbSearchQuery
|
||||
: !localOnly
|
||||
? popularQuery
|
||||
: null;
|
||||
const tmdbPeople = activeQuery?.data?.pages.flatMap((p) => p.results) ?? [];
|
||||
|
||||
// Flatten paginated local results
|
||||
@@ -49,7 +54,7 @@ export function PeoplePage() {
|
||||
// Apply client-side favorite filter
|
||||
const filteredLocalPeople = useMemo(() => {
|
||||
if (!localOnly) return [];
|
||||
if (filter === 'favorite') {
|
||||
if (filter === "favorite") {
|
||||
return allLocalPeople.filter((p: any) => p.favorite);
|
||||
}
|
||||
return allLocalPeople;
|
||||
@@ -68,16 +73,31 @@ export function PeoplePage() {
|
||||
observerRef.current = new IntersectionObserver((entries) => {
|
||||
if (!entries[0].isIntersecting) return;
|
||||
if (localOnly) {
|
||||
if (localPeopleQuery.hasNextPage && !localPeopleQuery.isFetchingNextPage) {
|
||||
if (
|
||||
localPeopleQuery.hasNextPage &&
|
||||
!localPeopleQuery.isFetchingNextPage
|
||||
) {
|
||||
localPeopleQuery.fetchNextPage();
|
||||
}
|
||||
} else if (activeQuery && !activeQuery.isFetchingNextPage && activeQuery.hasNextPage) {
|
||||
} else if (
|
||||
activeQuery &&
|
||||
!activeQuery.isFetchingNextPage &&
|
||||
activeQuery.hasNextPage
|
||||
) {
|
||||
activeQuery.fetchNextPage();
|
||||
}
|
||||
});
|
||||
observerRef.current.observe(node);
|
||||
},
|
||||
[localOnly, localPeopleQuery.hasNextPage, localPeopleQuery.isFetchingNextPage, localPeopleQuery.fetchNextPage, activeQuery?.isFetchingNextPage, activeQuery?.hasNextPage, activeQuery?.fetchNextPage]
|
||||
[
|
||||
localOnly,
|
||||
localPeopleQuery.hasNextPage,
|
||||
localPeopleQuery.isFetchingNextPage,
|
||||
localPeopleQuery.fetchNextPage,
|
||||
activeQuery?.isFetchingNextPage,
|
||||
activeQuery?.hasNextPage,
|
||||
activeQuery?.fetchNextPage,
|
||||
],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -160,7 +180,11 @@ export function PeoplePage() {
|
||||
style={{ animationDelay: `${Math.min(index * 20, 300)}ms` }}
|
||||
>
|
||||
<Link
|
||||
to={localOnly ? `/people/${person.id}` : `/people/tmdb/${person.id}`}
|
||||
to={
|
||||
localOnly
|
||||
? `/people/${person.id}`
|
||||
: `/people/tmdb/${person.id}`
|
||||
}
|
||||
className="group flex flex-col items-center gap-2 text-center"
|
||||
>
|
||||
<div className="relative">
|
||||
@@ -171,9 +195,9 @@ export function PeoplePage() {
|
||||
/>
|
||||
<AvatarFallback>
|
||||
{person.name
|
||||
.split(' ')
|
||||
.split(" ")
|
||||
.map((n: string) => n[0])
|
||||
.join('')}
|
||||
.join("")}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
{person.favorite && (
|
||||
|
||||
Reference in new issue
Block a user