refactor: optimize book details and pages fetching by using Promise.all for parallel requests

This commit is contained in:
Julien Froidefond
2025-10-08 07:52:46 +02:00
parent 93cbf82fe1
commit f317fb5122

View File

@@ -13,13 +13,11 @@ export class BookService extends BaseApiService {
return this.fetchWithCache<KomgaBookWithPages>(
`book-${bookId}`,
async () => {
// Récupération des détails du tome
const book = await this.fetchFromApi<KomgaBook>({ path: `books/${bookId}` });
// Récupération des pages du tome
const pages = await this.fetchFromApi<{ number: number }[]>({
path: `books/${bookId}/pages`,
});
// Récupération parallèle des détails du tome et des pages
const [book, pages] = await Promise.all([
this.fetchFromApi<KomgaBook>({ path: `books/${bookId}` }),
this.fetchFromApi<{ number: number }[]>({ path: `books/${bookId}/pages` })
]);
return {
book,