refacto: type mutu
This commit is contained in:
@@ -4,6 +4,7 @@ import { redirect } from "next/navigation";
|
|||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
import { withPageTiming } from "@/lib/hoc/withPageTiming";
|
import { withPageTiming } from "@/lib/hoc/withPageTiming";
|
||||||
import { ErrorMessage } from "@/components/ui/ErrorMessage";
|
import { ErrorMessage } from "@/components/ui/ErrorMessage";
|
||||||
|
import { HomeData } from "@/lib/services/home.service";
|
||||||
|
|
||||||
async function refreshHome() {
|
async function refreshHome() {
|
||||||
"use server";
|
"use server";
|
||||||
@@ -20,7 +21,7 @@ async function refreshHome() {
|
|||||||
|
|
||||||
async function HomePage() {
|
async function HomePage() {
|
||||||
try {
|
try {
|
||||||
const data = await HomeService.getHomeData();
|
const data: HomeData = await HomeService.getHomeData();
|
||||||
|
|
||||||
return <HomeContent data={data} refreshHome={refreshHome} />;
|
return <HomeContent data={data} refreshHome={refreshHome} />;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -3,14 +3,7 @@ import { MediaRow } from "./MediaRow";
|
|||||||
import { KomgaBook, KomgaSeries } from "@/types/komga";
|
import { KomgaBook, KomgaSeries } from "@/types/komga";
|
||||||
import { RefreshButton } from "@/components/library/RefreshButton";
|
import { RefreshButton } from "@/components/library/RefreshButton";
|
||||||
import { History, Sparkles, Clock, LibraryBig, BookOpen } from "lucide-react";
|
import { History, Sparkles, Clock, LibraryBig, BookOpen } from "lucide-react";
|
||||||
|
import { HomeData } from "@/lib/services/home.service";
|
||||||
interface HomeData {
|
|
||||||
ongoing: KomgaSeries[];
|
|
||||||
ongoingBooks: KomgaBook[];
|
|
||||||
recentlyRead: KomgaBook[];
|
|
||||||
onDeck: KomgaBook[];
|
|
||||||
latestSeries: KomgaSeries[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface HomeContentProps {
|
interface HomeContentProps {
|
||||||
data: HomeData;
|
data: HomeData;
|
||||||
@@ -30,7 +23,7 @@ export function HomeContent({ data, refreshHome }: HomeContentProps) {
|
|||||||
id,
|
id,
|
||||||
metadata: { title: metadata.title },
|
metadata: { title: metadata.title },
|
||||||
booksCount,
|
booksCount,
|
||||||
booksReadCount
|
booksReadCount,
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -39,7 +32,7 @@ export function HomeContent({ data, refreshHome }: HomeContentProps) {
|
|||||||
id,
|
id,
|
||||||
metadata: { title: metadata.title },
|
metadata: { title: metadata.title },
|
||||||
booksCount,
|
booksCount,
|
||||||
booksReadCount
|
booksReadCount,
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -51,7 +44,7 @@ export function HomeContent({ data, refreshHome }: HomeContentProps) {
|
|||||||
number: metadata.number,
|
number: metadata.number,
|
||||||
},
|
},
|
||||||
readProgress: readProgress || { page: 0 },
|
readProgress: readProgress || { page: 0 },
|
||||||
media
|
media,
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,20 +3,7 @@
|
|||||||
import React, { createContext, useContext, useEffect, useState } from "react";
|
import React, { createContext, useContext, useEffect, useState } from "react";
|
||||||
import { ERROR_CODES } from "../constants/errorCodes";
|
import { ERROR_CODES } from "../constants/errorCodes";
|
||||||
import { AppError } from "../utils/errors";
|
import { AppError } from "../utils/errors";
|
||||||
|
import { UserPreferences, defaultPreferences } from "@/types/preferences";
|
||||||
export interface UserPreferences {
|
|
||||||
showThumbnails: boolean;
|
|
||||||
cacheMode: "memory" | "file";
|
|
||||||
showOnlyUnread: boolean;
|
|
||||||
debug: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaultPreferences: UserPreferences = {
|
|
||||||
showThumbnails: true,
|
|
||||||
cacheMode: "memory",
|
|
||||||
showOnlyUnread: false,
|
|
||||||
debug: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
interface PreferencesContextType {
|
interface PreferencesContextType {
|
||||||
preferences: UserPreferences;
|
preferences: UserPreferences;
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import { getServerCacheService } from "./server-cache.service";
|
|||||||
import { ERROR_CODES } from "../../constants/errorCodes";
|
import { ERROR_CODES } from "../../constants/errorCodes";
|
||||||
import { AppError } from "../../utils/errors";
|
import { AppError } from "../../utils/errors";
|
||||||
|
|
||||||
interface HomeData {
|
export interface HomeData {
|
||||||
ongoing: KomgaSeries[];
|
ongoing: KomgaSeries[];
|
||||||
ongoingBooks: KomgaBook[]; // Nouveau champ
|
ongoingBooks: KomgaBook[];
|
||||||
recentlyRead: KomgaBook[];
|
recentlyRead: KomgaBook[];
|
||||||
onDeck: KomgaBook[];
|
onDeck: KomgaBook[];
|
||||||
latestSeries: KomgaSeries[];
|
latestSeries: KomgaSeries[];
|
||||||
|
|||||||
@@ -2,26 +2,13 @@ import { PreferencesModel } from "@/lib/models/preferences.model";
|
|||||||
import { AuthServerService } from "./auth-server.service";
|
import { AuthServerService } from "./auth-server.service";
|
||||||
import { ERROR_CODES } from "../../constants/errorCodes";
|
import { ERROR_CODES } from "../../constants/errorCodes";
|
||||||
import { AppError } from "../../utils/errors";
|
import { AppError } from "../../utils/errors";
|
||||||
|
import { UserPreferences, defaultPreferences } from "@/types/preferences";
|
||||||
|
|
||||||
interface User {
|
interface User {
|
||||||
id: string;
|
id: string;
|
||||||
email: 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 {
|
export class PreferencesService {
|
||||||
static getCurrentUser(): User {
|
static getCurrentUser(): User {
|
||||||
const user = AuthServerService.getCurrentUser();
|
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;
|
||||||
12
yarn.lock
12
yarn.lock
@@ -226,7 +226,7 @@
|
|||||||
|
|
||||||
"@jridgewell/gen-mapping@^0.3.2":
|
"@jridgewell/gen-mapping@^0.3.2":
|
||||||
version "0.3.8"
|
version "0.3.8"
|
||||||
resolved "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz"
|
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz#4f0e06362e01362f823d348f1872b08f666d8142"
|
||||||
integrity sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==
|
integrity sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@jridgewell/set-array" "^1.2.1"
|
"@jridgewell/set-array" "^1.2.1"
|
||||||
@@ -250,7 +250,7 @@
|
|||||||
|
|
||||||
"@jridgewell/trace-mapping@^0.3.24":
|
"@jridgewell/trace-mapping@^0.3.24":
|
||||||
version "0.3.25"
|
version "0.3.25"
|
||||||
resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz"
|
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz#15f190e98895f3fc23276ee14bc76b675c2e50f0"
|
||||||
integrity sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==
|
integrity sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@jridgewell/resolve-uri" "^3.1.0"
|
"@jridgewell/resolve-uri" "^3.1.0"
|
||||||
@@ -970,7 +970,7 @@ any-promise@^1.0.0:
|
|||||||
|
|
||||||
anymatch@~3.1.2:
|
anymatch@~3.1.2:
|
||||||
version "3.1.3"
|
version "3.1.3"
|
||||||
resolved "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz"
|
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e"
|
||||||
integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==
|
integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==
|
||||||
dependencies:
|
dependencies:
|
||||||
normalize-path "^3.0.0"
|
normalize-path "^3.0.0"
|
||||||
@@ -1008,7 +1008,7 @@ aria-hidden@^1.1.1:
|
|||||||
|
|
||||||
aria-query@^5.3.2:
|
aria-query@^5.3.2:
|
||||||
version "5.3.2"
|
version "5.3.2"
|
||||||
resolved "https://registry.npmjs.org/aria-query/-/aria-query-5.3.2.tgz"
|
resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-5.3.2.tgz#93f81a43480e33a338f19163a3d10a50c01dcd59"
|
||||||
integrity sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==
|
integrity sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==
|
||||||
|
|
||||||
array-buffer-byte-length@^1.0.1, array-buffer-byte-length@^1.0.2:
|
array-buffer-byte-length@^1.0.1, array-buffer-byte-length@^1.0.2:
|
||||||
@@ -1984,7 +1984,7 @@ fs.realpath@^1.0.0:
|
|||||||
|
|
||||||
fsevents@~2.3.2:
|
fsevents@~2.3.2:
|
||||||
version "2.3.3"
|
version "2.3.3"
|
||||||
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz"
|
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
|
||||||
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
|
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
|
||||||
|
|
||||||
function-bind@^1.1.2:
|
function-bind@^1.1.2:
|
||||||
@@ -3109,7 +3109,7 @@ pify@^2.3.0:
|
|||||||
|
|
||||||
pirates@^4.0.1:
|
pirates@^4.0.1:
|
||||||
version "4.0.6"
|
version "4.0.6"
|
||||||
resolved "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz"
|
resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.6.tgz#3018ae32ecfcff6c29ba2267cbf21166ac1f36b9"
|
||||||
integrity sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==
|
integrity sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==
|
||||||
|
|
||||||
possible-typed-array-names@^1.0.0:
|
possible-typed-array-names@^1.0.0:
|
||||||
|
|||||||
Reference in New Issue
Block a user