fix: invalidate library series cache when read progress changes
Some checks failed
Deploy with Docker Compose / deploy (push) Failing after 48s

- 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
This commit is contained in:
2026-03-02 13:27:59 +01:00
parent 4288e4c541
commit 30e3529be3
3 changed files with 16 additions and 5 deletions

View File

@@ -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,
{

View File

@@ -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) {

View File

@@ -31,6 +31,8 @@ const sortSeriesDeterministically = <T extends { id: string; metadata?: { titleS
});
};
export const LIBRARY_SERIES_CACHE_TAG = "library-series";
export class LibraryService extends BaseApiService {
private static readonly CACHE_TTL = 300; // 5 minutes
@@ -134,7 +136,12 @@ export class LibraryService extends BaseApiService {
const response = await this.fetchFromApi<LibraryResponse<Series>>(
{ 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);