fix: lints
This commit is contained in:
1
src/app/api/komga/cache/mode/route.ts
vendored
1
src/app/api/komga/cache/mode/route.ts
vendored
@@ -18,6 +18,7 @@ export async function POST(request: Request) {
|
|||||||
serverCacheService.setCacheMode(mode);
|
serverCacheService.setCacheMode(mode);
|
||||||
return NextResponse.json({ mode: serverCacheService.getCacheMode() });
|
return NextResponse.json({ mode: serverCacheService.getCacheMode() });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error("Erreur lors de la mise à jour du mode de cache:", error);
|
||||||
return NextResponse.json({ error: "Invalid request" }, { status: 400 });
|
return NextResponse.json({ error: "Invalid request" }, { status: 400 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable @next/next/no-img-element */
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { BookReaderProps } from "./types";
|
import { BookReaderProps } from "./types";
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export function CacheModeSwitch() {
|
|||||||
description: `Le cache est maintenant en mode ${checked ? "mémoire" : "fichier"}`,
|
description: `Le cache est maintenant en mode ${checked ? "mémoire" : "fichier"}`,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error("Erreur lors de la modification du mode de cache:", error);
|
||||||
toast({
|
toast({
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
title: "Erreur",
|
title: "Erreur",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { ImageOff } from "lucide-react";
|
import { ImageOff } from "lucide-react";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { useState, useEffect, useRef } from "react";
|
import { useState, useEffect, useRef, useCallback } from "react";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { ImageLoader } from "@/components/ui/image-loader";
|
import { ImageLoader } from "@/components/ui/image-loader";
|
||||||
|
|
||||||
@@ -29,23 +29,21 @@ export function Cover({
|
|||||||
}: CoverProps) {
|
}: CoverProps) {
|
||||||
const [imageError, setImageError] = useState(false);
|
const [imageError, setImageError] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [isInViewport, setIsInViewport] = useState(false);
|
|
||||||
const [imageUrl, setImageUrl] = useState<string | null>(null);
|
const [imageUrl, setImageUrl] = useState<string | null>(null);
|
||||||
const coverRef = useRef<HTMLDivElement>(null);
|
const coverRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const getImageUrl = () => {
|
const getImageUrl = useCallback(() => {
|
||||||
if (type === "series") {
|
if (type === "series") {
|
||||||
return `/api/komga/images/series/${id}/thumbnail`;
|
return `/api/komga/images/series/${id}/thumbnail`;
|
||||||
}
|
}
|
||||||
return `/api/komga/images/books/${id}/thumbnail`;
|
return `/api/komga/images/books/${id}/thumbnail`;
|
||||||
};
|
}, [type, id]);
|
||||||
|
|
||||||
// Observer pour détecter quand la cover est dans le viewport
|
// Observer pour détecter quand la cover est dans le viewport
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const observer = new IntersectionObserver(
|
const observer = new IntersectionObserver(
|
||||||
(entries) => {
|
(entries) => {
|
||||||
entries.forEach((entry) => {
|
entries.forEach((entry) => {
|
||||||
setIsInViewport(entry.isIntersecting);
|
|
||||||
if (entry.isIntersecting && !imageUrl) {
|
if (entry.isIntersecting && !imageUrl) {
|
||||||
setImageUrl(getImageUrl());
|
setImageUrl(getImageUrl());
|
||||||
}
|
}
|
||||||
@@ -66,7 +64,7 @@ export function Cover({
|
|||||||
observer.unobserve(element);
|
observer.unobserve(element);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, [id, imageUrl]);
|
}, [id, imageUrl, getImageUrl]);
|
||||||
|
|
||||||
if (imageError) {
|
if (imageError) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export function MarkAsReadButton({
|
|||||||
});
|
});
|
||||||
onSuccess?.();
|
onSuccess?.();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error("Erreur lors de la mise à jour du progresseur de lecture:", error);
|
||||||
toast({
|
toast({
|
||||||
title: "Erreur",
|
title: "Erreur",
|
||||||
description: "Impossible de marquer le tome comme lu",
|
description: "Impossible de marquer le tome comme lu",
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import connectDB from "@/lib/mongodb";
|
|
||||||
import { PreferencesModel } from "@/lib/models/preferences.model";
|
import { PreferencesModel } from "@/lib/models/preferences.model";
|
||||||
|
|
||||||
interface User {
|
interface User {
|
||||||
|
|||||||
@@ -74,7 +74,8 @@ class ServerCacheService {
|
|||||||
if (isSubDirEmpty) {
|
if (isSubDirEmpty) {
|
||||||
try {
|
try {
|
||||||
fs.rmdirSync(itemPath);
|
fs.rmdirSync(itemPath);
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
|
console.error(`Could not remove directory ${itemPath}:`, error);
|
||||||
isEmpty = false;
|
isEmpty = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -89,18 +90,21 @@ class ServerCacheService {
|
|||||||
} else {
|
} else {
|
||||||
isEmpty = false;
|
isEmpty = false;
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
|
console.error(`Could not parse file ${itemPath}:`, error);
|
||||||
// Si le fichier est corrompu, on le supprime
|
// Si le fichier est corrompu, on le supprime
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(itemPath);
|
fs.unlinkSync(itemPath);
|
||||||
} catch (_) {
|
} catch (error) {
|
||||||
|
console.error(`Could not remove file ${itemPath}:`, error);
|
||||||
isEmpty = false;
|
isEmpty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
isEmpty = false;
|
isEmpty = false;
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
|
console.error(`Could not access ${itemPath}:`, error);
|
||||||
// En cas d'erreur sur le fichier/dossier, on continue
|
// En cas d'erreur sur le fichier/dossier, on continue
|
||||||
isEmpty = false;
|
isEmpty = false;
|
||||||
continue;
|
continue;
|
||||||
@@ -146,7 +150,6 @@ class ServerCacheService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.config.mode = mode;
|
this.config.mode = mode;
|
||||||
console.log(`Cache mode switched to: ${mode}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCacheMode(): CacheMode {
|
public getCacheMode(): CacheMode {
|
||||||
@@ -174,11 +177,13 @@ class ServerCacheService {
|
|||||||
const key = path.relative(this.cacheDir, itemPath).slice(0, -5); // Remove .json
|
const key = path.relative(this.cacheDir, itemPath).slice(0, -5); // Remove .json
|
||||||
this.memoryCache.set(key, cached);
|
this.memoryCache.set(key, cached);
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
|
console.error(`Could not parse file ${itemPath}:`, error);
|
||||||
// Ignore les fichiers corrompus
|
// Ignore les fichiers corrompus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
|
console.error(`Could not access ${itemPath}:`, error);
|
||||||
// Ignore les erreurs d'accès
|
// Ignore les erreurs d'accès
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,8 +201,8 @@ class ServerCacheService {
|
|||||||
fs.mkdirSync(dirPath, { recursive: true });
|
fs.mkdirSync(dirPath, { recursive: true });
|
||||||
}
|
}
|
||||||
fs.writeFileSync(filePath, JSON.stringify(value), "utf-8");
|
fs.writeFileSync(filePath, JSON.stringify(value), "utf-8");
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
// Ignore les erreurs d'écriture
|
console.error(`Could not write cache file ${filePath}:`, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,25 +308,24 @@ class ServerCacheService {
|
|||||||
removeDirectory(itemPath);
|
removeDirectory(itemPath);
|
||||||
try {
|
try {
|
||||||
fs.rmdirSync(itemPath);
|
fs.rmdirSync(itemPath);
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
console.error(`Could not remove directory ${itemPath}`);
|
console.error(`Could not remove directory ${itemPath}:`, error);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(itemPath);
|
fs.unlinkSync(itemPath);
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
console.error(`Could not remove file ${itemPath}`);
|
console.error(`Could not remove file ${itemPath}:`, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
console.error(`Error accessing ${itemPath}`);
|
console.error(`Error accessing ${itemPath}:`, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
removeDirectory(this.cacheDir);
|
removeDirectory(this.cacheDir);
|
||||||
console.log("Cache cleared successfully");
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error clearing cache:", error);
|
console.error("Error clearing cache:", error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user