fix: sync reactive state with data prop using \$effect
Replaces bare \$state(data.x) initialisers (which only capture the initial value) with \$state + \$effect pairs so that state stays in sync whenever page data is invalidated or the URL changes. Affects all list pages (searchValue) and all edit/detail pages (form fields). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,20 @@
|
||||
let selectedModelIds = $state<string[]>(
|
||||
data.video.models?.map((m: { id: string }) => m.id) ?? [],
|
||||
);
|
||||
$effect(() => {
|
||||
title = data.video.title;
|
||||
slug = data.video.slug;
|
||||
description = data.video.description ?? "";
|
||||
tags = data.video.tags ?? [];
|
||||
premium = data.video.premium ?? false;
|
||||
featured = data.video.featured ?? false;
|
||||
uploadDate = data.video.upload_date
|
||||
? new Date(data.video.upload_date).toISOString().slice(0, 16)
|
||||
: "";
|
||||
imageId = data.video.image ?? null;
|
||||
movieId = data.video.movie ?? null;
|
||||
selectedModelIds = data.video.models?.map((m: { id: string }) => m.id) ?? [];
|
||||
});
|
||||
let saving = $state(false);
|
||||
|
||||
async function handleImageUpload(files: File[]) {
|
||||
|
||||
Reference in New Issue
Block a user