mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 01:35:39 -04:00
Refactor auth session handling and server actions across app
- Overhaul `lib/auth/server.ts` and `lib/auth/session.ts`; update all API routes and server actions to use the revised session pattern - Refactor server actions (settings, titles, watchlist, setup) for consistency with new auth layer - Extract `SetupForm` into its own client component with `useActionState`, animated steps, and copyable env snippets - Move landing page redirect logic into `app/page.tsx`; slim down `LandingPage` component - Add `proxy.ts` for local dev proxying - Minor cleanup to `NavBar`, `MobileTabBar`, and `TitleCard`
This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
||||
import { type MotionStyle, type MotionValue, motion } from "motion/react";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
@@ -83,8 +83,15 @@ function QuickAddButton({
|
||||
userStatus ?? null,
|
||||
);
|
||||
|
||||
const effectiveStatus = addedStatus;
|
||||
const config = effectiveStatus ? statusConfig[effectiveStatus] : null;
|
||||
// Sync local state when prop changes (e.g. after navigation or SWR revalidation)
|
||||
useEffect(() => {
|
||||
if (userStatus) {
|
||||
setState("added");
|
||||
setAddedStatus(userStatus);
|
||||
}
|
||||
}, [userStatus]);
|
||||
|
||||
const config = addedStatus ? statusConfig[addedStatus] : null;
|
||||
|
||||
async function handleClick(e: React.MouseEvent) {
|
||||
e.preventDefault();
|
||||
@@ -92,13 +99,9 @@ function QuickAddButton({
|
||||
if (state === "loading" || state === "added") return;
|
||||
setState("loading");
|
||||
try {
|
||||
const result = await quickAddToWatchlist(tmdbId, type);
|
||||
await quickAddToWatchlist(tmdbId, type);
|
||||
setState("added");
|
||||
setAddedStatus(result.alreadyAdded ? null : "watchlist");
|
||||
if (result.alreadyAdded) {
|
||||
// Already existed — keep as added but we don't know exact status
|
||||
setAddedStatus("watchlist");
|
||||
}
|
||||
setAddedStatus("watchlist");
|
||||
} catch {
|
||||
setState("idle");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user