fix: revalidate /libraries cache after settings updates
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 42s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 42s
Add revalidatePath("/libraries") to the monitoring, metadata-provider
and reading-status-provider route handlers so that saving library
settings invalidates the Next.js data cache and the page reflects
fresh data on reload.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { revalidatePath } from "next/cache";
|
||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { apiFetch, LibraryDto } from "@/lib/api";
|
import { apiFetch, LibraryDto } from "@/lib/api";
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ export async function PATCH(
|
|||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
});
|
});
|
||||||
|
revalidatePath("/libraries");
|
||||||
return NextResponse.json(data);
|
return NextResponse.json(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = error instanceof Error ? error.message : "Failed to update metadata provider";
|
const message = error instanceof Error ? error.message : "Failed to update metadata provider";
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { revalidatePath } from "next/cache";
|
||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { updateLibraryMonitoring } from "@/lib/api";
|
import { updateLibraryMonitoring } from "@/lib/api";
|
||||||
|
|
||||||
@@ -9,6 +10,7 @@ export async function PATCH(
|
|||||||
try {
|
try {
|
||||||
const { monitor_enabled, scan_mode, watcher_enabled, metadata_refresh_mode } = await request.json();
|
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);
|
const data = await updateLibraryMonitoring(id, monitor_enabled, scan_mode, watcher_enabled, metadata_refresh_mode);
|
||||||
|
revalidatePath("/libraries");
|
||||||
return NextResponse.json(data);
|
return NextResponse.json(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = error instanceof Error ? error.message : "Failed to update monitoring settings";
|
const message = error instanceof Error ? error.message : "Failed to update monitoring settings";
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { revalidatePath } from "next/cache";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { apiFetch } from "@/lib/api";
|
import { apiFetch } from "@/lib/api";
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@ export async function PATCH(
|
|||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
});
|
});
|
||||||
|
revalidatePath("/libraries");
|
||||||
return NextResponse.json(data);
|
return NextResponse.json(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = error instanceof Error ? error.message : "Failed to update reading status provider";
|
const message = error instanceof Error ? error.message : "Failed to update reading status provider";
|
||||||
|
|||||||
Reference in New Issue
Block a user