Skip to content

Commit 636d04e

Browse files
Mary Hipppsychedelicious
authored andcommitted
rehydrate selectedImage URL when results and uploads are fetched
1 parent 63db3fc commit 636d04e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

invokeai/frontend/web/src/features/gallery/store/gallerySlice.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import type { PayloadAction } from '@reduxjs/toolkit';
22
import { createSlice } from '@reduxjs/toolkit';
33
import { Image } from 'app/types/invokeai';
44
import { imageReceived, thumbnailReceived } from 'services/thunks/image';
5+
import {
6+
receivedResultImagesPage,
7+
receivedUploadImagesPage,
8+
} from '../../../services/thunks/gallery';
59

610
type GalleryImageObjectFitType = 'contain' | 'cover';
711

@@ -86,6 +90,30 @@ export const gallerySlice = createSlice({
8690
state.selectedImage.thumbnail = thumbnailPath;
8791
}
8892
});
93+
builder.addCase(receivedResultImagesPage.fulfilled, (state, action) => {
94+
// rehydrate selectedImage URL when results list comes in
95+
// solves case when outdated URL is in local storage
96+
if (state.selectedImage) {
97+
const selectedImageInResults = action.payload.items.find(
98+
(image) => image.image_name === state.selectedImage!.name
99+
);
100+
if (selectedImageInResults) {
101+
state.selectedImage.url = selectedImageInResults.image_url;
102+
}
103+
}
104+
});
105+
builder.addCase(receivedUploadImagesPage.fulfilled, (state, action) => {
106+
// rehydrate selectedImage URL when results list comes in
107+
// solves case when outdated URL is in local storage
108+
if (state.selectedImage) {
109+
const selectedImageInResults = action.payload.items.find(
110+
(image) => image.image_name === state.selectedImage!.name
111+
);
112+
if (selectedImageInResults) {
113+
state.selectedImage.url = selectedImageInResults.image_url;
114+
}
115+
}
116+
});
89117
},
90118
});
91119

0 commit comments

Comments
 (0)