@wordpress/upload-media
Version:
Core media upload logic.
61 lines (56 loc) • 1.44 kB
JavaScript
/**
* Internal dependencies
*/
/**
* Returns all items currently being uploaded.
*
* @param state Upload state.
*
* @return Queue items.
*/
export 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.
*/
export 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.
*/
export 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.
*/
export 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
*/
export function getSettings(state) {
return state.settings;
}
//# sourceMappingURL=selectors.js.map