From 654a9b4130949f59dd91e066a97b8341d4889ecc Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Sun, 24 Sep 2023 17:31:52 +0200 Subject: [PATCH] Frontend: Add checks if variables are defined in photo.js #2040 Signed-off-by: Michael Mayer --- frontend/src/model/photo.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/model/photo.js b/frontend/src/model/photo.js index eed8042aa..eb5b26dd4 100644 --- a/frontend/src/model/photo.js +++ b/frontend/src/model/photo.js @@ -543,6 +543,10 @@ export class Photo extends RestModel { } getOriginalFileFromFiles = memoizeOne((files) => { + if (!files) { + return this; + } + // Find first original media file with a format other than JPEG. let file = files.find((f) => !f.Sidecar && f.Root === "/" && f.FileType !== FormatJpeg); if (file) { @@ -804,13 +808,15 @@ export class Photo extends RestModel { } } + if (!file.Size) { + return; + } + if (file.Size > 102400) { const size = Number.parseFloat(file.Size) / 1048576; - info.push(size.toFixed(1) + " MB"); - } else if (file.Size) { + } else { const size = Number.parseFloat(file.Size) / 1024; - info.push(size.toFixed(1) + " KB"); } }