refacto: type mutu
This commit is contained in:
@@ -4,6 +4,7 @@ import { redirect } from "next/navigation";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { withPageTiming } from "@/lib/hoc/withPageTiming";
|
||||
import { ErrorMessage } from "@/components/ui/ErrorMessage";
|
||||
import { HomeData } from "@/lib/services/home.service";
|
||||
|
||||
async function refreshHome() {
|
||||
"use server";
|
||||
@@ -20,7 +21,7 @@ async function refreshHome() {
|
||||
|
||||
async function HomePage() {
|
||||
try {
|
||||
const data = await HomeService.getHomeData();
|
||||
const data: HomeData = await HomeService.getHomeData();
|
||||
|
||||
return <HomeContent data={data} refreshHome={refreshHome} />;
|
||||
} catch (error) {
|
||||
|
||||
@@ -3,14 +3,7 @@ import { MediaRow } from "./MediaRow";
|
||||
import { KomgaBook, KomgaSeries } from "@/types/komga";
|
||||
import { RefreshButton } from "@/components/library/RefreshButton";
|
||||
import { History, Sparkles, Clock, LibraryBig, BookOpen } from "lucide-react";
|
||||
|
||||
interface HomeData {
|
||||
ongoing: KomgaSeries[];
|
||||
ongoingBooks: KomgaBook[];
|
||||
recentlyRead: KomgaBook[];
|
||||
onDeck: KomgaBook[];
|
||||
latestSeries: KomgaSeries[];
|
||||
}
|
||||
import { HomeData } from "@/lib/services/home.service";
|
||||
|
||||
interface HomeContentProps {
|
||||
data: HomeData;
|
||||
@@ -30,7 +23,7 @@ export function HomeContent({ data, refreshHome }: HomeContentProps) {
|
||||
id,
|
||||
metadata: { title: metadata.title },
|
||||
booksCount,
|
||||
booksReadCount
|
||||
booksReadCount,
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -39,7 +32,7 @@ export function HomeContent({ data, refreshHome }: HomeContentProps) {
|
||||
id,
|
||||
metadata: { title: metadata.title },
|
||||
booksCount,
|
||||
booksReadCount
|
||||
booksReadCount,
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -51,7 +44,7 @@ export function HomeContent({ data, refreshHome }: HomeContentProps) {
|
||||
number: metadata.number,
|
||||
},
|
||||
readProgress: readProgress || { page: 0 },
|
||||
media
|
||||
media,
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
@@ -3,20 +3,7 @@
|
||||
import React, { createContext, useContext, useEffect, useState } from "react";
|
||||
import { ERROR_CODES } from "../constants/errorCodes";
|
||||
import { AppError } from "../utils/errors";
|
||||
|
||||
export interface UserPreferences {
|
||||
showThumbnails: boolean;
|
||||
cacheMode: "memory" | "file";
|
||||
showOnlyUnread: boolean;
|
||||
debug: boolean;
|
||||
}
|
||||
|
||||
const defaultPreferences: UserPreferences = {
|
||||
showThumbnails: true,
|
||||
cacheMode: "memory",
|
||||
showOnlyUnread: false,
|
||||
debug: false,
|
||||
};
|
||||
import { UserPreferences, defaultPreferences } from "@/types/preferences";
|
||||
|
||||
interface PreferencesContextType {
|
||||
preferences: UserPreferences;
|
||||
|
||||
@@ -5,9 +5,9 @@ import { getServerCacheService } from "./server-cache.service";
|
||||
import { ERROR_CODES } from "../../constants/errorCodes";
|
||||
import { AppError } from "../../utils/errors";
|
||||
|
||||
interface HomeData {
|
||||
export interface HomeData {
|
||||
ongoing: KomgaSeries[];
|
||||
ongoingBooks: KomgaBook[]; // Nouveau champ
|
||||
ongoingBooks: KomgaBook[];
|
||||
recentlyRead: KomgaBook[];
|
||||
onDeck: KomgaBook[];
|
||||
latestSeries: KomgaSeries[];
|
||||
|
||||
@@ -2,26 +2,13 @@ import { PreferencesModel } from "@/lib/models/preferences.model";
|
||||
import { AuthServerService } from "./auth-server.service";
|
||||
import { ERROR_CODES } from "../../constants/errorCodes";
|
||||
import { AppError } from "../../utils/errors";
|
||||
import { UserPreferences, defaultPreferences } from "@/types/preferences";
|
||||
|
||||
interface User {
|
||||
id: string;
|
||||
email: string;
|
||||
}
|
||||
|
||||
export interface UserPreferences {
|
||||
showThumbnails: boolean;
|
||||
cacheMode: "memory" | "file";
|
||||
showOnlyUnread: boolean;
|
||||
debug: boolean;
|
||||
}
|
||||
|
||||
const defaultPreferences: UserPreferences = {
|
||||
showThumbnails: true,
|
||||
cacheMode: "memory",
|
||||
showOnlyUnread: false,
|
||||
debug: false,
|
||||
};
|
||||
|
||||
export class PreferencesService {
|
||||
static getCurrentUser(): User {
|
||||
const user = AuthServerService.getCurrentUser();
|
||||
|
||||
13
src/types/preferences.ts
Normal file
13
src/types/preferences.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export interface UserPreferences {
|
||||
showThumbnails: boolean;
|
||||
cacheMode: "memory" | "file";
|
||||
showOnlyUnread: boolean;
|
||||
debug: boolean;
|
||||
}
|
||||
|
||||
export const defaultPreferences: UserPreferences = {
|
||||
showThumbnails: true,
|
||||
cacheMode: "memory",
|
||||
showOnlyUnread: false,
|
||||
debug: false,
|
||||
} as const;
|
||||
Reference in New Issue
Block a user