Handling when file_group or file is sent to path getters.

This commit is contained in:
Roland 2023-03-27 11:37:00 -06:00
parent 7e23e2cfff
commit 5bd1e39f0e
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93

View file

@ -10,16 +10,28 @@ import {
ModalHeader
} from "semantic-ui-react";
function getMediaPathURL(path) {
return `/media/${encodeURIComponent(path['path'])}`;
function getMediaPathURL(file) {
if (file['primary_path']) {
return `/media/${encodeURIComponent(file['primary_path'])}`;
} else {
return `/media/${encodeURIComponent(file['path'])}`;
}
}
function getDownloadPathURL(path) {
return `/download/${encodeURIComponent(path['path'])}`;
function getDownloadPathURL(file) {
if (file['primary_path']) {
return `/download/${encodeURIComponent(file['primary_path'])}`;
} else {
return `/download/${encodeURIComponent(file['path'])}`;
}
}
function getEpubViewerURL(path) {
return `/epub.html?url=download/${encodeURIComponent(path['path'])}`;
function getEpubViewerURL(file) {
if (file['primary_path']) {
return `/epub.html?url=download/${encodeURIComponent(file['primary_path'])}`;
} else {
return `/epub.html?url=download/${encodeURIComponent(file['path'])}`;
}
}
function getIframeModal(path) {
@ -143,7 +155,8 @@ export function FilePreviewWrapper({children}) {
}
if (previewFile && !_.isEmpty(previewFile)) {
const {mimetype, size, path} = previewFile;
const {mimetype, size} = previewFile;
const path = previewFile['primary_path'] || previewFile['path'];
const lowerPath = path.toLowerCase();
console.debug(`useFilePreview path=${previewFile['path']} mimetype=${mimetype}`);
const url = getMediaPathURL(previewFile);