Files
InvokeAI/invokeai/frontend/web/src/services/api/hooks/useDebouncedMetadata.ts
psychedelicious 189c430e46 chore(ui): format
Lots of changed bc the line length is now 120. May as well do it now.
2024-01-28 19:57:53 +11:00

15 lines
606 B
TypeScript

import { skipToken } from '@reduxjs/toolkit/query';
import { useAppSelector } from 'app/store/storeHooks';
import { useGetImageMetadataQuery } from 'services/api/endpoints/images';
import { useDebounce } from 'use-debounce';
export const useDebouncedMetadata = (imageName?: string | null) => {
const metadataFetchDebounce = useAppSelector((s) => s.config.metadataFetchDebounce ?? 300);
const [debouncedImageName] = useDebounce(imageName, metadataFetchDebounce);
const { data: metadata, isLoading } = useGetImageMetadataQuery(debouncedImageName ?? skipToken);
return { metadata, isLoading };
};