mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 00:25:38 -04:00
- Add composite indexes on userEpisodeWatches and userMovieWatches for hot queries - Batch episode tracking: wrap season/batch watches in single transaction (~8 queries vs 8*N) - Fix N+1 patterns in credits, recommendations, and filmography with batch prefetch+insert - Stream TV season hydration via Suspense instead of blocking page render - Optimize webhook logs (per-connection LIMIT 10) and system health queries - Merge genre filter waterfalls into single Promise.all fetch - Migrate deprecated Jotai loadable() to unwrap() - Replace isolated createStore()+Provider with useHydrateAtoms on root store - Remove unnecessary atomWithStorage SSR guards (handled by Jotai internally) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
46 lines
934 B
TypeScript
46 lines
934 B
TypeScript
"use client";
|
|
|
|
import { useHydrateAtoms } from "jotai/utils";
|
|
import {
|
|
episodeWatchesAtom,
|
|
seasonsAtom,
|
|
titleIdAtom,
|
|
titleNameAtom,
|
|
titleTypeAtom,
|
|
userRatingAtom,
|
|
userStatusAtom,
|
|
} from "@/lib/atoms/title";
|
|
import type { Season } from "@/lib/types/title";
|
|
|
|
export function TitleProvider({
|
|
titleId,
|
|
titleType,
|
|
titleName,
|
|
initialStatus,
|
|
initialRating,
|
|
initialEpisodeWatches,
|
|
seasons,
|
|
children,
|
|
}: {
|
|
titleId: string;
|
|
titleType: "movie" | "tv";
|
|
titleName: string;
|
|
initialStatus: string | null;
|
|
initialRating: number;
|
|
initialEpisodeWatches: string[];
|
|
seasons: Season[];
|
|
children: React.ReactNode;
|
|
}) {
|
|
useHydrateAtoms([
|
|
[titleIdAtom, titleId],
|
|
[titleTypeAtom, titleType],
|
|
[titleNameAtom, titleName],
|
|
[seasonsAtom, seasons],
|
|
[userStatusAtom, initialStatus],
|
|
[userRatingAtom, initialRating],
|
|
[episodeWatchesAtom, initialEpisodeWatches],
|
|
]);
|
|
|
|
return children;
|
|
}
|