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>( return this.fetchWithCache<KomgaBookWithPages>(
`book-${bookId}`, `book-${bookId}`,
async () => { async () => {
// Récupération des détails du tome // Récupération parallèle des détails du tome et des pages
const book = await this.fetchFromApi<KomgaBook>({ path: `books/${bookId}` }); const [book, pages] = await Promise.all([
this.fetchFromApi<KomgaBook>({ path: `books/${bookId}` }),
// Récupération des pages du tome this.fetchFromApi<{ number: number }[]>({ path: `books/${bookId}/pages` })
const pages = await this.fetchFromApi<{ number: number }[]>({ ]);
path: `books/${bookId}/pages`,
});
return { return {
book, book,