fix : download and loading
This commit is contained in:
@@ -44,23 +44,25 @@ export function LoadingBar() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const originalFetch = window.fetch;
|
const originalFetch = window.fetch;
|
||||||
|
|
||||||
window.fetch = async function(...args) {
|
window.fetch = async function (...args) {
|
||||||
const url = args[0].toString();
|
const url = args[0].toString();
|
||||||
const isStaticRequest = /\.(css|js|png|jpg|jpeg|gif|webp|svg|ico|mp3|mp4|webm|ttf|woff|woff2)$/.test(url);
|
const isStaticRequest =
|
||||||
|
/\.(css|js|png|jpg|jpeg|gif|webp|svg|ico|mp3|mp4|webm|ttf|woff|woff2)$/.test(url);
|
||||||
if (!isStaticRequest) {
|
const isBookPageRequest = url.includes("/api/komga/images/books/") && url.includes("/pages");
|
||||||
|
|
||||||
|
if (!isStaticRequest && !isBookPageRequest) {
|
||||||
pendingRequestsRef.current++;
|
pendingRequestsRef.current++;
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await originalFetch.apply(this, args);
|
const response = await originalFetch.apply(this, args);
|
||||||
return response;
|
return response;
|
||||||
} finally {
|
} finally {
|
||||||
if (!isStaticRequest) {
|
if (!isStaticRequest && !isBookPageRequest) {
|
||||||
pendingRequestsRef.current = Math.max(0, pendingRequestsRef.current - 1);
|
pendingRequestsRef.current = Math.max(0, pendingRequestsRef.current - 1);
|
||||||
|
|
||||||
if (pendingRequestsRef.current === 0) {
|
if (pendingRequestsRef.current === 0) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user