@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
8 lines (7 loc) • 1.67 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/utils/media-upload/on-success.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { dispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Invalidates core-data entity records for uploaded attachments so that\n * blocks re-fetch updated data (e.g. `media_details.sizes` after\n * thumbnails have been generated via client-side media processing).\n *\n * @param {Object[]} attachments Array of attachment objects from the upload queue.\n */\nexport default function mediaUploadOnSuccess( attachments ) {\n\tconst { invalidateResolution } = dispatch( coreDataStore );\n\tfor ( const attachment of attachments ) {\n\t\tif ( attachment.id ) {\n\t\t\t// Invalidate with and without the query argument, since\n\t\t\t// resolution keys must exactly match the args used by\n\t\t\t// each consumer's getEntityRecord() call.\n\t\t\tinvalidateResolution( 'getEntityRecord', [\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\tattachment.id,\n\t\t\t\t{ context: 'view' },\n\t\t\t] );\n\t\t\tinvalidateResolution( 'getEntityRecord', [\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\tattachment.id,\n\t\t\t] );\n\t\t}\n\t}\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAyB;AACzB,uBAAuC;AASxB,SAAR,qBAAuC,aAAc;AAC3D,QAAM,EAAE,qBAAqB,QAAI,sBAAU,iBAAAA,KAAc;AACzD,aAAY,cAAc,aAAc;AACvC,QAAK,WAAW,IAAK;AAIpB,2BAAsB,mBAAmB;AAAA,QACxC;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX,EAAE,SAAS,OAAO;AAAA,MACnB,CAAE;AACF,2BAAsB,mBAAmB;AAAA,QACxC;AAAA,QACA;AAAA,QACA,WAAW;AAAA,MACZ,CAAE;AAAA,IACH;AAAA,EACD;AACD;",
"names": ["coreDataStore"]
}