feat: refresh in libraries and books lists
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { BaseApiService } from "./base-api.service";
|
||||
import { Library, LibraryResponse } from "@/types/library";
|
||||
import { Series } from "@/types/series";
|
||||
import { serverCacheService } from "./server-cache.service";
|
||||
|
||||
export class LibraryService extends BaseApiService {
|
||||
static async getLibraries(): Promise<Library[]> {
|
||||
@@ -53,4 +54,8 @@ export class LibraryService extends BaseApiService {
|
||||
return this.handleError(error, "Impossible de récupérer les séries");
|
||||
}
|
||||
}
|
||||
|
||||
static async clearLibrarySeriesCache(libraryId: string) {
|
||||
serverCacheService.delete(`library-${libraryId}-series`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { KomgaBook, KomgaSeries } from "@/types/komga";
|
||||
import { BookService } from "./book.service";
|
||||
import { ImageService } from "./image.service";
|
||||
import { PreferencesService } from "./preferences.service";
|
||||
import { serverCacheService } from "./server-cache.service";
|
||||
|
||||
export class SeriesService extends BaseApiService {
|
||||
static async getSeries(seriesId: string): Promise<KomgaSeries> {
|
||||
@@ -22,6 +23,10 @@ export class SeriesService extends BaseApiService {
|
||||
}
|
||||
}
|
||||
|
||||
static async clearSeriesCache(seriesId: string) {
|
||||
serverCacheService.delete(`series-${seriesId}`);
|
||||
}
|
||||
|
||||
static async getSeriesBooks(
|
||||
seriesId: string,
|
||||
page: number = 0,
|
||||
@@ -48,6 +53,10 @@ export class SeriesService extends BaseApiService {
|
||||
}
|
||||
}
|
||||
|
||||
static async clearSeriesBooksCache(seriesId: string) {
|
||||
serverCacheService.deleteAll(`series-${seriesId}-books`);
|
||||
}
|
||||
|
||||
static async getFirstBook(seriesId: string): Promise<string> {
|
||||
try {
|
||||
const config = await this.getKomgaConfig();
|
||||
|
||||
@@ -283,6 +283,24 @@ class ServerCacheService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Supprime toutes les entrées du cache qui commencent par un préfixe
|
||||
*/
|
||||
deleteAll(prefix: string): void {
|
||||
if (this.config.mode === "memory") {
|
||||
this.memoryCache.forEach((value, key) => {
|
||||
if (key.startsWith(prefix)) {
|
||||
this.memoryCache.delete(key);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
const cacheDir = path.join(this.cacheDir, prefix);
|
||||
if (fs.existsSync(cacheDir)) {
|
||||
fs.rmdirSync(cacheDir, { recursive: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Vide le cache
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user