From 0c612304bfab66370b9f1498398c38bf6073b34d Mon Sep 17 00:00:00 2001 From: Louis Mollick Date: Mon, 14 Oct 2024 04:01:09 -0400 Subject: [PATCH] feat: move image to server component to see if it preloads correctly --- .../[volumeNumber]/[pageNumber]/page.tsx | 25 ++++++++++++++----- src/app/_components/mangaPageView.tsx | 16 +++--------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/app/[mangaSlug]/[volumeNumber]/[pageNumber]/page.tsx b/src/app/[mangaSlug]/[volumeNumber]/[pageNumber]/page.tsx index c50f159..371d995 100644 --- a/src/app/[mangaSlug]/[volumeNumber]/[pageNumber]/page.tsx +++ b/src/app/[mangaSlug]/[volumeNumber]/[pageNumber]/page.tsx @@ -1,3 +1,4 @@ +import Image from "next/image"; import MangaPageView from "@/app/_components/mangaPageView"; import safelyReadOcrFile from "@/lib/ocr/safelyReadOcrFile"; @@ -12,11 +13,23 @@ export default async function MangaPage({ if (!ocr) return
Page not found.
; return ( - + <> + + } + /> + ); } diff --git a/src/app/_components/mangaPageView.tsx b/src/app/_components/mangaPageView.tsx index 36559e5..6d8ded1 100644 --- a/src/app/_components/mangaPageView.tsx +++ b/src/app/_components/mangaPageView.tsx @@ -19,7 +19,6 @@ import { Tabs, TabsList, TabsTrigger } from "@/app/_components/ui/tabs"; import { cn } from "@/lib/ui/utils"; import WordReadingContent from "@/app/_components/wordReadingContent"; import useKeyPress from "@/app/_hooks/useKeyPress"; -import { PrefetchKind } from "next/dist/client/components/router-reducer/router-reducer-types"; const Language = { enUS: "en-US", @@ -36,11 +35,13 @@ const MangaPageView = ({ volumeNumber, pageNumber, ocr, + image, }: { mangaSlug: string; volumeNumber: string; pageNumber: string; ocr: MokuroResponse; + image: React.ReactNode; }) => { const router = useRouter(); // const volumeNumberParsed = parseInt(volumeNumber, 10); @@ -69,8 +70,6 @@ const MangaPageView = ({ const [selectedWordId, setSelectedWordId] = useState(null); const wordRefs = useRef>(new Map()); - const imgPath = `/images/${mangaSlug}/${language}/volume-${volumeNumber}/${pageNumber.padStart(3, "0")}.JPG`; - const scrollWordReadingIntoView = (wordId: string) => wordRefs.current.get(wordId)?.scrollIntoView({ behavior: "smooth", @@ -164,19 +163,12 @@ const MangaPageView = ({ >
{language === Language.jpJP && speechBubbles} - {`${mangaSlug} + {image}