From d47da16014350375b15887fe2cc821e4926cbab5 Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Sun, 16 Mar 2025 21:20:09 +0100 Subject: [PATCH] fix : download and loading --- src/components/ui/loading-bar.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/ui/loading-bar.tsx b/src/components/ui/loading-bar.tsx index d870e55..e3b438e 100644 --- a/src/components/ui/loading-bar.tsx +++ b/src/components/ui/loading-bar.tsx @@ -44,23 +44,25 @@ export function LoadingBar() { useEffect(() => { const originalFetch = window.fetch; - - window.fetch = async function(...args) { + + window.fetch = async function (...args) { const url = args[0].toString(); - const isStaticRequest = /\.(css|js|png|jpg|jpeg|gif|webp|svg|ico|mp3|mp4|webm|ttf|woff|woff2)$/.test(url); - - if (!isStaticRequest) { + const isStaticRequest = + /\.(css|js|png|jpg|jpeg|gif|webp|svg|ico|mp3|mp4|webm|ttf|woff|woff2)$/.test(url); + const isBookPageRequest = url.includes("/api/komga/images/books/") && url.includes("/pages"); + + if (!isStaticRequest && !isBookPageRequest) { pendingRequestsRef.current++; setIsLoading(true); } - + try { const response = await originalFetch.apply(this, args); return response; } finally { - if (!isStaticRequest) { + if (!isStaticRequest && !isBookPageRequest) { pendingRequestsRef.current = Math.max(0, pendingRequestsRef.current - 1); - + if (pendingRequestsRef.current === 0) { setTimeout(() => { setIsLoading(false);