fix(ui): fix auto-switch to new images

This commit is contained in:
psychedelicious 2023-05-29 16:03:31 +10:00 committed by Kent Keirsey
parent 6f82801d07
commit 043f9d9ba4

View File

@ -1,6 +1,7 @@
import type { PayloadAction } from '@reduxjs/toolkit';
import { createSlice } from '@reduxjs/toolkit';
import { ImageDTO } from 'services/api';
import { imageUpserted } from './imagesSlice';
type GalleryImageObjectFitType = 'contain' | 'cover';
@ -47,6 +48,13 @@ export const gallerySlice = createSlice({
state.shouldUseSingleGalleryColumn = action.payload;
},
},
extraReducers: (builder) => {
builder.addCase(imageUpserted, (state, action) => {
if (state.shouldAutoSwitchToNewImages) {
state.selectedImage = action.payload;
}
});
},
});
export const {