From fe33acedade495a77db5d0e96ae4c332aca5452f Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 21 Jul 2023 15:57:09 +1000 Subject: [PATCH] fix(ui): fix crash when removing last image --- .../web/src/features/gallery/hooks/useNextPrevImage.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/invokeai/frontend/web/src/features/gallery/hooks/useNextPrevImage.ts b/invokeai/frontend/web/src/features/gallery/hooks/useNextPrevImage.ts index 1dc0e2c10d..7b4b8bed7b 100644 --- a/invokeai/frontend/web/src/features/gallery/hooks/useNextPrevImage.ts +++ b/invokeai/frontend/web/src/features/gallery/hooks/useNextPrevImage.ts @@ -52,8 +52,8 @@ export const nextPrevImageButtonsSelector = createSelector( const prevImageIndex = clamp(currentImageIndex - 1, 0, images.length - 1); - const nextImageId = images[nextImageIndex].image_name; - const prevImageId = images[prevImageIndex].image_name; + const nextImageId = images[nextImageIndex]?.image_name; + const prevImageId = images[prevImageIndex]?.image_name; const nextImage = selectors.selectById(data, nextImageId); const prevImage = selectors.selectById(data, prevImageId);