UNPKG

@wordpress/media-utils

Version:
21 lines (20 loc) 859 B
// packages/media-utils/src/components/media-upload-modal/use-invalidate-attachment-resolutions.ts import { useCallback } from "@wordpress/element"; import { store as coreStore } from "@wordpress/core-data"; import { useRegistry } from "@wordpress/data"; function useInvalidateAttachmentResolutions() { const registry = useRegistry(); return useCallback(() => { const resolvers = registry.select(coreStore).getCachedResolvers(); const entityRecordResolutions = resolvers.getEntityRecords; entityRecordResolutions?.forEach((_value, args) => { if (args[0] === "postType" && args[1] === "attachment") { registry.dispatch(coreStore).invalidateResolution("getEntityRecords", args); } }); }, [registry]); } export { useInvalidateAttachmentResolutions }; //# sourceMappingURL=use-invalidate-attachment-resolutions.mjs.map