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(() => { useEffect(() => {
if (cancel.status === 'success') { if (cancel.status === 'success') {
clearLoading(); clearLoading(props.loading);
} }
}, [cancel.status]); }, [cancel.status]);

View File

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