Filters existing images when adding new images; Fixes #1085; Builds fresh bundle

This commit is contained in:
psychedelicious
2022-10-20 08:16:43 +08:00
committed by Lincoln Stein
parent 3e0a7b6229
commit 213e12fe13
4 changed files with 18 additions and 5 deletions

View File

@@ -72,7 +72,13 @@ export const gallerySlice = createSlice({
},
addImage: (state, action: PayloadAction<InvokeAI.Image>) => {
const newImage = action.payload;
const { uuid, mtime } = newImage;
const { uuid, url, mtime } = newImage;
// Do not add duplicate images
if (state.images.find((i) => i.url === url && i.mtime === mtime)) {
return;
}
state.images.unshift(newImage);
state.currentImageUuid = uuid;
state.intermediateImage = undefined;
@@ -120,8 +126,15 @@ export const gallerySlice = createSlice({
) => {
const { images, areMoreImagesAvailable } = action.payload;
if (images.length > 0) {
// Filter images that already exist in the gallery
const newImages = images.filter(
(newImage) =>
!state.images.find(
(i) => i.url === newImage.url && i.mtime === newImage.mtime
)
);
state.images = state.images
.concat(images)
.concat(newImages)
.sort((a, b) => b.mtime - a.mtime);
if (!state.currentImage) {

View File

@@ -15,7 +15,7 @@ export default function MainCFGScale() {
label="CFG Scale"
step={0.5}
min={1}
max={200}
max={30}
onChange={handleChangeCfgScale}
value={cfgScale}
width={inputWidth}