From 2c5de102b2165a10a7f3a604947fa4f4fab4e16d Mon Sep 17 00:00:00 2001 From: Abhinav Date: Wed, 26 Jan 2022 11:54:49 +0530 Subject: [PATCH] prevent files[index] is undefined errors --- src/components/PhotoFrame.tsx | 51 ++++++++++++++++++----------------- src/components/PhotoList.tsx | 2 +- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/components/PhotoFrame.tsx b/src/components/PhotoFrame.tsx index fd44b89cd..d399a9055 100644 --- a/src/components/PhotoFrame.tsx +++ b/src/components/PhotoFrame.tsx @@ -334,30 +334,33 @@ const PhotoFrame = ({ handleSelect(filteredData[index].id, index)(!checked); } }; - const getThumbnail = (files: EnteFile[], index: number) => ( - 0} - onHover={onHoverOver(index)} - onRangeSelect={handleRangeSelect(index)} - isRangeSelectActive={isShiftKeyPressed && selected.count > 0} - isInsSelectRange={ - (index >= rangeStart && index <= currentHover) || - (index >= currentHover && index <= rangeStart) - } - /> - ); + const getThumbnail = (files: EnteFile[], index: number) => + files[index] ? ( + 0} + onHover={onHoverOver(index)} + onRangeSelect={handleRangeSelect(index)} + isRangeSelectActive={isShiftKeyPressed && selected.count > 0} + isInsSelectRange={ + (index >= rangeStart && index <= currentHover) || + (index >= currentHover && index <= rangeStart) + } + /> + ) : ( + <> + ); const getSlideData = async ( instance: any, diff --git a/src/components/PhotoList.tsx b/src/components/PhotoList.tsx index 577694a25..9ebc1186b 100644 --- a/src/components/PhotoList.tsx +++ b/src/components/PhotoList.tsx @@ -439,7 +439,7 @@ export function PhotoList({ } } }; - if (!timeStampList) { + if (!timeStampList?.length) { return <>; }