From 1d4f61c7bdbca4934b3628839bb4a5d9e1907a00 Mon Sep 17 00:00:00 2001 From: Roland Date: Wed, 28 Dec 2022 19:49:18 -0700 Subject: [PATCH] Creating EbookRowCells to handle displaying ebook covers in list view. --- app/src/components/Files.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/app/src/components/Files.js b/app/src/components/Files.js index 2e6babc8..28183320 100644 --- a/app/src/components/Files.js +++ b/app/src/components/Files.js @@ -31,7 +31,7 @@ import { PageContainer, Paginator, textEllipsis, - useTitle + useTitle, CardLink } from "./Common"; import {useBrowseFiles, useQuery, useSearchFiles} from "../hooks/customHooks"; import {Route, Routes} from "react-router-dom"; @@ -326,13 +326,44 @@ function ImageRowCells({file}) { ) } +export function EbookRowCells({file}) { + const {ebook} = file; + + const downloadUrl = `/download/${encodeURIComponent(file.path)}`; + const viewerUrl = file['mimetype'].startsWith('application/epub') ? `/epub.html?url=${downloadUrl}` : null; + + let cover = ; + if (ebook && ebook.cover_path) { + const coverSrc = `/media/${encodeURIComponent(ebook.cover_path)}`; + cover = ; + } + + // Fragment for SelectableRow + return ( + +
{cover}
+
+ + + {textEllipsis(ebook.title || file.title)} + + +
) +} + function FileRow({file}) { + const isEbookType = file.mimetype && ( + file.mimetype.startsWith('application/epub') || file.mimetype.startsWith('application/x-mobipocket-ebook') + ); + if (file.model === 'video' && 'video' in file) { return ; } else if (file.model === 'archive' && 'archive' in file) { return ; } else if (file.mimetype && file.mimetype.startsWith('image/')) { return ; + } else if (isEbookType) { + return ; } const onDownloadFile = async () => window.open(`/media/${file.key}`);