UNPKG

@wordpress/media-utils

Version:
46 lines (44 loc) 2.07 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // packages/media-utils/src/components/media-upload-modal/use-invalidate-attachment-resolutions.ts var use_invalidate_attachment_resolutions_exports = {}; __export(use_invalidate_attachment_resolutions_exports, { useInvalidateAttachmentResolutions: () => useInvalidateAttachmentResolutions }); module.exports = __toCommonJS(use_invalidate_attachment_resolutions_exports); var import_element = require("@wordpress/element"); var import_core_data = require("@wordpress/core-data"); var import_data = require("@wordpress/data"); function useInvalidateAttachmentResolutions() { const registry = (0, import_data.useRegistry)(); return (0, import_element.useCallback)(() => { const resolvers = registry.select(import_core_data.store).getCachedResolvers(); const entityRecordResolutions = resolvers.getEntityRecords; entityRecordResolutions?.forEach((_value, args) => { if (args[0] === "postType" && args[1] === "attachment") { registry.dispatch(import_core_data.store).invalidateResolution("getEntityRecords", args); } }); }, [registry]); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { useInvalidateAttachmentResolutions }); //# sourceMappingURL=use-invalidate-attachment-resolutions.cjs.map