fix: pass metadata_refresh_mode through backoffice proxy to API

The Next.js monitoring route was dropping metadata_refresh_mode from the
request body, so the value was never forwarded to the Rust API and
reverted on reload.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-20 10:46:22 +01:00
parent 4d69ed91c5
commit d08fe31b1b
2 changed files with 9 additions and 2 deletions

View File

@@ -7,8 +7,8 @@ export async function PATCH(
) {
const { id } = await params;
try {
const { monitor_enabled, scan_mode, watcher_enabled } = await request.json();
const data = await updateLibraryMonitoring(id, monitor_enabled, scan_mode, watcher_enabled);
const { monitor_enabled, scan_mode, watcher_enabled, metadata_refresh_mode } = await request.json();
const data = await updateLibraryMonitoring(id, monitor_enabled, scan_mode, watcher_enabled, metadata_refresh_mode);
return NextResponse.json(data);
} catch (error) {
const message = error instanceof Error ? error.message : "Failed to update monitoring settings";

View File

@@ -10,6 +10,8 @@ export type LibraryDto = {
watcher_enabled: boolean;
metadata_provider: string | null;
fallback_metadata_provider: string | null;
metadata_refresh_mode: string;
next_metadata_refresh_at: string | null;
};
export type IndexJobDto = {
@@ -192,11 +194,13 @@ export async function updateLibraryMonitoring(
monitorEnabled: boolean,
scanMode: string,
watcherEnabled?: boolean,
metadataRefreshMode?: string,
) {
const body: {
monitor_enabled: boolean;
scan_mode: string;
watcher_enabled?: boolean;
metadata_refresh_mode?: string;
} = {
monitor_enabled: monitorEnabled,
scan_mode: scanMode,
@@ -204,6 +208,9 @@ export async function updateLibraryMonitoring(
if (watcherEnabled !== undefined) {
body.watcher_enabled = watcherEnabled;
}
if (metadataRefreshMode !== undefined) {
body.metadata_refresh_mode = metadataRefreshMode;
}
return apiFetch<LibraryDto>(`/libraries/${libraryId}/monitoring`, {
method: "PATCH",
body: JSON.stringify(body),