"use client";
import { useRef, useState, useTransition } from "react";
import { useRouter } from "next/navigation";
import { clsx } from "clsx";
import { setTagsAction, updateEntryAction } from "@/app/actions/library";
import { useToasts } from "@/components/Toasts";
/**
* Notizfeld, „wo schaue ich das" und eigene Tags.
*
* Gespeichert wird beim Verlassen des Feldes, nicht bei jedem Tastendruck —
* das spart Anfragen und erspart das Suchen nach einem Speichern-Knopf.
*/
export function EntryNotes({
entryId,
notes,
whereToWatch,
tags,
suggestion,
owned,
ownedSource,
}: {
entryId: string;
notes: string | null;
whereToWatch: string | null;
tags: string[];
/** Vorschlag aus der Streaming-Verfügbarkeit. */
suggestion: string | null;
owned: boolean;
ownedSource: string | null;
}) {
return (
);
}
/**
* „Hab ich" — der Titel liegt in der eigenen Sammlung.
*
* Bewusst getrennt von „wo schaue ich das": Streaming-Verfügbarkeit kommt und
* geht, der gekaufte Film auf dem Heimserver bleibt. Genau die Titel, die
* nirgends mehr laufen, will man ja wiederfinden.
*/
function OwnedEditor({
entryId,
owned,
source,
}: {
entryId: string;
owned: boolean;
source: string | null;
}) {
const save = useAutosave(entryId);
const [isOwned, setIsOwned] = useState(owned);
const [text, setText] = useState(source ?? "");
const initial = useRef(source ?? "");
return (
{isOwned && (
setText(event.target.value)}
onBlur={() => {
if (text === initial.current) return;
initial.current = text;
save({ ownedSource: text });
}}
list="fl-owned-quellen"
placeholder="Jellyfin, Plex, NAS, Blu-ray …"
className="fl-input py-1.5 text-sm"
/>