1
0
Fork 0

fix(gui): clear loading state for image when it enters history

This commit is contained in:
Sean Sube 2023-02-04 12:30:03 -06:00
parent 732aa27b92
commit 7181d62fba
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
2 changed files with 8 additions and 6 deletions

View File

@ -62,7 +62,7 @@ export function LoadingCard(props: LoadingCardProps) {
useEffect(() => {
if (cancel.status === 'success') {
clearLoading();
clearLoading(props.loading);
}
}, [cancel.status]);

View File

@ -46,12 +46,14 @@ interface HistorySlice {
limit: number;
loading: Array<LoadingItem>;
// TODO: hack until setLoading removes things
clearLoading(): void;
clearLoading(image: ImageResponse): void;
pushHistory(image: ImageResponse): void;
pushLoading(image: ImageResponse): void;
removeHistory(image: ImageResponse): void;
setLimit(limit: number): void;
/**
* @todo should check ready and move the image from loading to history
*/
setReady(image: ImageResponse, ready: ReadyResponse): void;
}
@ -274,10 +276,10 @@ export function createStateSlices(server: ServerParams) {
history: [],
limit: DEFAULT_HISTORY.limit,
loading: [],
clearLoading() {
clearLoading(image) {
set((prev) => ({
...prev,
loading: [],
loading: prev.loading.filter((it) => it.image.output.key !== image.output.key),
}));
},
pushHistory(image) {
@ -287,7 +289,7 @@ export function createStateSlices(server: ServerParams) {
image,
...prev.history,
].slice(0, prev.limit + DEFAULT_HISTORY.scrollback),
loading: [],
loading: prev.loading.filter((it) => it.image.output.key !== image.output.key),
}));
},
pushLoading(image) {