diff --git a/src/app/@file.grid.tsx b/src/app/@file.grid.tsx index 236a60d..ac5d9ba 100644 --- a/src/app/@file.grid.tsx +++ b/src/app/@file.grid.tsx @@ -51,6 +51,9 @@ export default function FileGrid({ data }: Props) { return new URL(path, config.basePath).pathname; }, [data, pathname]); + const [thumbnailURL, setThumbnailURL] = useState( + `/api/thumb/${data.encryptedId}?size=2`, + ); const [actionOpen, setActionOpen] = useState(false); const isDesktop = useMediaQuery("(min-width: 768px)"); @@ -220,13 +223,23 @@ export default function FileGrid({ data }: Props) { data.mimeType.startsWith("image")) ? ( <> {data.name} { + if (thumbnailURL.includes("size=2")) { + setThumbnailURL(`/api/thumb/${data.encryptedId}`); + } + }} className='rounded-top-[var(--radius)] absolute -z-0 h-32 w-full flex-shrink-0 flex-grow-0 object-cover opacity-50' /> {data.name} { + if (thumbnailURL.includes("size=2")) { + setThumbnailURL(`/api/thumb/${data.encryptedId}`); + } + }} className='relative z-0 h-32 w-full flex-shrink-0 flex-grow-0 object-contain backdrop-blur' /> diff --git a/src/app/@file.list.tsx b/src/app/@file.list.tsx index 87041dd..0513e51 100644 --- a/src/app/@file.list.tsx +++ b/src/app/@file.list.tsx @@ -29,6 +29,7 @@ import { import useMediaQuery from "~/hooks/useMediaQuery"; import bytesToReadable from "~/utils/bytesFormat"; +import { durationToReadable } from "~/utils/durationFormat"; import { getPreviewIcon } from "~/utils/previewHelper"; import config from "~/config/gIndex.config"; @@ -42,14 +43,16 @@ export default function FileList({ data }: Props) { const pathname = usePathname(); const filePath = useMemo(() => { - // const currentPath = pathname.startsWith("/e") ? pathname : `/e${pathname}`; - // Set to pathname to remove the /e prefix const path = [pathname, encodeURIComponent(data.name)] .join("/") .replace(/\/+/g, "/"); return new URL(path, config.basePath).pathname; }, [data, pathname]); + + const [thumbnailURL, setThumbnailURL] = useState( + `/api/thumb/${data.encryptedId}?size=2`, + ); const [actionOpen, setActionOpen] = useState(false); const isDesktop = useMediaQuery("(min-width: 768px)"); @@ -218,9 +221,14 @@ export default function FileList({ data }: Props) { data.mimeType.startsWith("image")) ? ( <> {data.name} { + if (thumbnailURL.includes("size=2")) { + setThumbnailURL(`/api/thumb/${data.encryptedId}`); + } + }} + className='size-16 flex-shrink-0 flex-grow-0 rounded-[var(--radius)] object-cover tablet:size-20' /> {data.mimeType.startsWith("video") && ( @@ -230,6 +238,11 @@ export default function FileList({ data }: Props) { className='absolute left-1/2 top-1/2 z-10 -translate-x-1/2 -translate-y-1/2 rounded-full bg-muted-foreground fill-muted p-1.5 text-muted opacity-75' size={24} /> +
+ {durationToReadable( + data.videoMediaMetadata?.durationMillis || 0, + )} +
)} @@ -240,13 +253,13 @@ export default function FileList({ data }: Props) { ? "Folder" : getPreviewIcon(data.fileExtension || "", data.mimeType) } - className='size-16 flex-shrink-0 flex-grow-0 p-3 tablet:size-12' + className='size-16 flex-shrink-0 flex-grow-0 p-3 tablet:size-20' /> )} {/* File data */} -
+
{config.siteConfig.showFileExtension ? data.name