UNPKG

@wordpress/upload-media

Version:
71 lines (65 loc) 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getItems = getItems; exports.getSettings = getSettings; exports.isUploading = isUploading; exports.isUploadingById = isUploadingById; exports.isUploadingByUrl = isUploadingByUrl; /** * Internal dependencies */ /** * Returns all items currently being uploaded. * * @param state Upload state. * * @return Queue items. */ function getItems(state) { return state.queue; } /** * Determines whether any upload is currently in progress. * * @param state Upload state. * * @return Whether any upload is currently in progress. */ function isUploading(state) { return state.queue.length >= 1; } /** * Determines whether an upload is currently in progress given an attachment URL. * * @param state Upload state. * @param url Attachment URL. * * @return Whether upload is currently in progress for the given attachment. */ function isUploadingByUrl(state, url) { return state.queue.some(item => item.attachment?.url === url || item.sourceUrl === url); } /** * Determines whether an upload is currently in progress given an attachment ID. * * @param state Upload state. * @param attachmentId Attachment ID. * * @return Whether upload is currently in progress for the given attachment. */ function isUploadingById(state, attachmentId) { return state.queue.some(item => item.attachment?.id === attachmentId || item.sourceAttachmentId === attachmentId); } /** * Returns the media upload settings. * * @param state Upload state. * * @return Settings */ function getSettings(state) { return state.settings; } //# sourceMappingURL=selectors.js.map