feat: implement request monitoring and queuing services to manage concurrent requests to Komga
This commit is contained in:
@@ -22,7 +22,7 @@ export const Thumbnail = forwardRef<HTMLButtonElement, ThumbnailProps>(
|
||||
const [hasError, setHasError] = useState(false);
|
||||
const [isInViewport, setIsInViewport] = useState(false);
|
||||
const loadAttempts = useRef(0);
|
||||
const maxAttempts = 3;
|
||||
const maxAttempts = 1; // Désactivé pour réduire la charge sur Komga
|
||||
const internalRef = useRef<HTMLButtonElement>(null);
|
||||
|
||||
useImperativeHandle(ref, () => internalRef.current as HTMLButtonElement);
|
||||
@@ -94,7 +94,14 @@ export const Thumbnail = forwardRef<HTMLButtonElement, ThumbnailProps>(
|
||||
// Réessayer avec un délai croissant
|
||||
const delay = Math.min(1000 * Math.pow(2, loadAttempts.current - 1), 5000);
|
||||
setTimeout(() => {
|
||||
setImageUrl((prev) => (prev ? `${prev}?retry=${loadAttempts.current}` : null));
|
||||
setImageUrl((prev) => {
|
||||
if (!prev) return null;
|
||||
// Utiliser & si l'URL contient déjà des query params
|
||||
const separator = prev.includes('?') ? '&' : '?';
|
||||
// Supprimer l'ancien retry param si présent
|
||||
const baseUrl = prev.replace(/[?&]retry=\d+/g, '');
|
||||
return `${baseUrl}${separator}retry=${loadAttempts.current}`;
|
||||
});
|
||||
}, delay);
|
||||
} else {
|
||||
console.error(
|
||||
|
||||
@@ -23,7 +23,7 @@ export const useThumbnails = ({ book, currentPage }: UseThumbnailsProps) => {
|
||||
|
||||
// Mettre à jour les thumbnails visibles autour de la page courante
|
||||
useEffect(() => {
|
||||
const windowSize = 10; // Nombre de pages à charger de chaque côté
|
||||
const windowSize = 0; // DÉSACTIVÉ TEMPORAIREMENT: Thumbnails désactivés pour éviter de surcharger Komga
|
||||
const start = Math.max(1, currentPage - windowSize);
|
||||
const end = currentPage + windowSize;
|
||||
const newVisibleThumbnails = Array.from({ length: end - start + 1 }, (_, i) => start + i);
|
||||
|
||||
Reference in New Issue
Block a user