Fixes next/prev image not working if category doesn't match

This commit is contained in:
psychedelicious 2022-10-30 16:02:57 +11:00
parent 62c97dd7e6
commit e096eef049

View File

@ -157,7 +157,9 @@ export const gallerySlice = createSlice({
selectNextImage: (state, action: PayloadAction<GalleryCategory>) => {
const category = action.payload;
const { currentImage } = state;
const tempImages = state.categories[category].images;
if (!currentImage) return;
const tempImages =
state.categories[currentImage.category as GalleryCategory].images;
if (currentImage) {
const currentImageIndex = tempImages.findIndex(
@ -173,7 +175,9 @@ export const gallerySlice = createSlice({
selectPrevImage: (state, action: PayloadAction<GalleryCategory>) => {
const category = action.payload;
const { currentImage } = state;
const tempImages = state.categories[category].images;
if (!currentImage) return;
const tempImages =
state.categories[currentImage.category as GalleryCategory].images;
if (currentImage) {
const currentImageIndex = tempImages.findIndex(