Fixes another similar index error, simplifies logic

This commit is contained in:
psychedelicious 2022-11-20 07:28:25 +11:00 committed by blessedcoolant
parent 0c3ae232af
commit 7f999e9dfc

View File

@ -174,7 +174,7 @@ export const gallerySlice = createSlice({
const currentImageIndex = tempImages.findIndex(
(i) => i.uuid === currentImage.uuid
);
if (_.inRange(currentImageIndex, 0, tempImages.length - 1)) {
if (currentImageIndex < tempImages.length - 1) {
const newCurrentImage = tempImages[currentImageIndex + 1];
state.currentImage = newCurrentImage;
state.currentImageUuid = newCurrentImage.uuid;
@ -191,7 +191,7 @@ export const gallerySlice = createSlice({
const currentImageIndex = tempImages.findIndex(
(i) => i.uuid === currentImage.uuid
);
if (_.inRange(currentImageIndex, 1, tempImages.length + 1)) {
if (currentImageIndex > 0) {
const newCurrentImage = tempImages[currentImageIndex - 1];
state.currentImage = newCurrentImage;
state.currentImageUuid = newCurrentImage.uuid;