mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): refetch intermediates count when settings modal open
The `getIntermediatesCount` query is set to `refetchOnMountOrArgsChange`. The intention was for when the settings modal opens (i.e. mounts), the `getIntermediatesCount` query is refetched. But it doesn't work - modals only mount once, there is no lazy rendering for them. So we have to imperatively refetch, by refetching as we open the modal. Closes #5639
This commit is contained in:
parent
f972fe9836
commit
c2af124622
@ -81,9 +81,10 @@ const SettingsModal = ({ children, config }: SettingsModalProps) => {
|
|||||||
hasPendingItems,
|
hasPendingItems,
|
||||||
intermediatesCount,
|
intermediatesCount,
|
||||||
isLoading: isLoadingClearIntermediates,
|
isLoading: isLoadingClearIntermediates,
|
||||||
|
refetchIntermediatesCount,
|
||||||
} = useClearIntermediates(shouldShowClearIntermediates);
|
} = useClearIntermediates(shouldShowClearIntermediates);
|
||||||
|
|
||||||
const { isOpen: isSettingsModalOpen, onOpen: onSettingsModalOpen, onClose: onSettingsModalClose } = useDisclosure();
|
const { isOpen: isSettingsModalOpen, onOpen: _onSettingsModalOpen, onClose: onSettingsModalClose } = useDisclosure();
|
||||||
|
|
||||||
const { isOpen: isRefreshModalOpen, onOpen: onRefreshModalOpen, onClose: onRefreshModalClose } = useDisclosure();
|
const { isOpen: isRefreshModalOpen, onOpen: onRefreshModalOpen, onClose: onRefreshModalClose } = useDisclosure();
|
||||||
|
|
||||||
@ -99,6 +100,11 @@ const SettingsModal = ({ children, config }: SettingsModalProps) => {
|
|||||||
|
|
||||||
const clearStorage = useClearStorage();
|
const clearStorage = useClearStorage();
|
||||||
|
|
||||||
|
const handleOpenSettingsModel = useCallback(() => {
|
||||||
|
refetchIntermediatesCount();
|
||||||
|
_onSettingsModalOpen();
|
||||||
|
}, [_onSettingsModalOpen, refetchIntermediatesCount]);
|
||||||
|
|
||||||
const handleClickResetWebUI = useCallback(() => {
|
const handleClickResetWebUI = useCallback(() => {
|
||||||
clearStorage();
|
clearStorage();
|
||||||
onSettingsModalClose();
|
onSettingsModalClose();
|
||||||
@ -171,7 +177,7 @@ const SettingsModal = ({ children, config }: SettingsModalProps) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{cloneElement(children, {
|
{cloneElement(children, {
|
||||||
onClick: onSettingsModalOpen,
|
onClick: handleOpenSettingsModel,
|
||||||
})}
|
})}
|
||||||
|
|
||||||
<Modal isOpen={isSettingsModalOpen} onClose={onSettingsModalClose} size="2xl" isCentered>
|
<Modal isOpen={isSettingsModalOpen} onClose={onSettingsModalClose} size="2xl" isCentered>
|
||||||
|
@ -12,13 +12,14 @@ export type UseClearIntermediatesReturn = {
|
|||||||
clearIntermediates: () => void;
|
clearIntermediates: () => void;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
hasPendingItems: boolean;
|
hasPendingItems: boolean;
|
||||||
|
refetchIntermediatesCount: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useClearIntermediates = (shouldShowClearIntermediates: boolean): UseClearIntermediatesReturn => {
|
export const useClearIntermediates = (shouldShowClearIntermediates: boolean): UseClearIntermediatesReturn => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const { data: intermediatesCount } = useGetIntermediatesCountQuery(undefined, {
|
const { data: intermediatesCount, refetch: refetchIntermediatesCount } = useGetIntermediatesCountQuery(undefined, {
|
||||||
refetchOnMountOrArgChange: true,
|
refetchOnMountOrArgChange: true,
|
||||||
skip: !shouldShowClearIntermediates,
|
skip: !shouldShowClearIntermediates,
|
||||||
});
|
});
|
||||||
@ -58,5 +59,5 @@ export const useClearIntermediates = (shouldShowClearIntermediates: boolean): Us
|
|||||||
});
|
});
|
||||||
}, [t, _clearIntermediates, dispatch, hasPendingItems]);
|
}, [t, _clearIntermediates, dispatch, hasPendingItems]);
|
||||||
|
|
||||||
return { intermediatesCount, clearIntermediates, isLoading, hasPendingItems };
|
return { intermediatesCount, clearIntermediates, isLoading, hasPendingItems, refetchIntermediatesCount };
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user