From 30e3529be3f17687869ab5fc81cc913cb1062787 Mon Sep 17 00:00:00 2001 From: Froidefond Julien Date: Mon, 2 Mar 2026 13:27:59 +0100 Subject: [PATCH] fix: invalidate library series cache when read progress changes - Add LIBRARY_SERIES_CACHE_TAG to getLibrarySeries fetch - Revalidate library-series tag in updateReadProgress and deleteReadProgress - Add eslint ignores for temp/, .next/, node_modules/ Made-with: Cursor --- eslint.config.mjs | 1 + src/app/actions/read-progress.ts | 11 +++++++---- src/lib/services/library.service.ts | 9 ++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 3dbeeae..8069ef4 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -4,6 +4,7 @@ import nextTypescript from "eslint-config-next/typescript"; import unusedImports from "eslint-plugin-unused-imports"; export default defineConfig([ + { ignores: ["temp/**", ".next/**", "node_modules/**"] }, ...nextCoreWebVitals, ...nextTypescript, { diff --git a/src/app/actions/read-progress.ts b/src/app/actions/read-progress.ts index 68b34fa..d5367ec 100644 --- a/src/app/actions/read-progress.ts +++ b/src/app/actions/read-progress.ts @@ -2,6 +2,7 @@ import { revalidateTag } from "next/cache"; import { BookService } from "@/lib/services/book.service"; +import { LIBRARY_SERIES_CACHE_TAG } from "@/lib/services/library.service"; import { AppError } from "@/utils/errors"; const HOME_CACHE_TAG = "home-data"; @@ -18,8 +19,9 @@ export async function updateReadProgress( try { await BookService.updateReadProgress(bookId, page, completed); - // Invalider le cache de la home (sans refresh auto) - revalidateTag(HOME_CACHE_TAG, "max"); + // Invalider le cache home et libraries (statut de lecture des séries) + revalidateTag(HOME_CACHE_TAG); + revalidateTag(LIBRARY_SERIES_CACHE_TAG); return { success: true, message: "Progression mise à jour" }; } catch (error) { @@ -39,8 +41,9 @@ export async function deleteReadProgress( try { await BookService.deleteReadProgress(bookId); - // Invalider le cache de la home (sans refresh auto) - revalidateTag(HOME_CACHE_TAG, "max"); + // Invalider le cache home et libraries (statut de lecture des séries) + revalidateTag(HOME_CACHE_TAG); + revalidateTag(LIBRARY_SERIES_CACHE_TAG); return { success: true, message: "Progression supprimée" }; } catch (error) { diff --git a/src/lib/services/library.service.ts b/src/lib/services/library.service.ts index 9c22802..8bcec7b 100644 --- a/src/lib/services/library.service.ts +++ b/src/lib/services/library.service.ts @@ -31,6 +31,8 @@ const sortSeriesDeterministically = >( { path: "series/list", params }, headers, - { method: "POST", body: JSON.stringify(searchBody), revalidate: this.CACHE_TTL } + { + method: "POST", + body: JSON.stringify(searchBody), + revalidate: this.CACHE_TTL, + tags: [LIBRARY_SERIES_CACHE_TAG], + } ); const filteredContent = response.content.filter((series) => !series.deleted);