feat: implement DELETE API endpoint for cache invalidation in HomeService and update ClientHomePage to utilize it
This commit is contained in:
@@ -14,27 +14,10 @@ import {
|
||||
Filter,
|
||||
Calendar,
|
||||
} from "lucide-react";
|
||||
import type { CacheType } from "@/lib/services/base-api.service";
|
||||
import type { RequestTiming } from "@/types/debug";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useDebug } from "@/contexts/DebugContext";
|
||||
|
||||
interface RequestTiming {
|
||||
url: string;
|
||||
startTime: number;
|
||||
endTime: number;
|
||||
duration: number;
|
||||
timestamp: string;
|
||||
fromCache: boolean;
|
||||
cacheType?: CacheType;
|
||||
mongoAccess?: {
|
||||
operation: string;
|
||||
duration: number;
|
||||
};
|
||||
pageRender?: {
|
||||
page: string;
|
||||
};
|
||||
}
|
||||
|
||||
function formatTime(timestamp: string) {
|
||||
const date = new Date(timestamp);
|
||||
return date.toLocaleTimeString("fr-FR", {
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { HomeContent } from "./HomeContent";
|
||||
import { HomeService } from "@/lib/services/home.service";
|
||||
import { ErrorMessage } from "@/components/ui/ErrorMessage";
|
||||
import { HomePageSkeleton } from "@/components/skeletons/OptimizedSkeletons";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import type { HomeData } from "@/lib/services/home.service";
|
||||
import type { HomeData } from "@/types/home";
|
||||
|
||||
export function ClientHomePage() {
|
||||
const router = useRouter();
|
||||
@@ -51,8 +50,16 @@ export function ClientHomePage() {
|
||||
|
||||
const handleRefresh = async () => {
|
||||
try {
|
||||
await HomeService.invalidateHomeCache();
|
||||
// Invalider le cache via l'API
|
||||
const deleteResponse = await fetch("/api/komga/home", {
|
||||
method: "DELETE",
|
||||
});
|
||||
|
||||
if (!deleteResponse.ok) {
|
||||
throw new Error("Erreur lors de l'invalidation du cache");
|
||||
}
|
||||
|
||||
// Récupérer les nouvelles données
|
||||
const response = await fetch("/api/komga/home");
|
||||
|
||||
if (!response.ok) {
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
import { HeroSection } from "./HeroSection";
|
||||
import { MediaRow } from "./MediaRow";
|
||||
import type { KomgaBook, KomgaSeries } from "@/types/komga";
|
||||
import type { HomeData } from "@/types/home";
|
||||
import { RefreshButton } from "@/components/library/RefreshButton";
|
||||
import { History, Sparkles, Clock, LibraryBig, BookOpen } from "lucide-react";
|
||||
import type { HomeData } from "@/lib/services/home.service";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user