UNPKG

@wordpress/upload-media

Version:
83 lines (82 loc) 2.77 kB
// packages/upload-media/src/store/private-selectors.ts import { OperationType } from "./types.mjs"; function getAllItems(state) { return state.queue; } function getItem(state, id) { return state.queue.find((item) => item.id === id); } function isBatchUploaded(state, batchId) { const batchItems = state.queue.filter( (item) => batchId === item.batchId ); return batchItems.length === 0; } function isPaused(state) { return state.queueStatus === "paused"; } function getBlobUrls(state, id) { return state.blobUrls[id] || []; } function getActiveUploadCount(state) { return state.queue.filter( (item) => item.currentOperation === OperationType.Upload ).length; } function getPendingUploads(state) { return state.queue.filter((item) => { const nextOperation = Array.isArray(item.operations?.[0]) ? item.operations[0][0] : item.operations?.[0]; return nextOperation === OperationType.Upload && item.currentOperation !== OperationType.Upload; }); } function getActiveImageProcessingCount(state) { return state.queue.filter( (item) => item.currentOperation === OperationType.ResizeCrop || item.currentOperation === OperationType.Rotate ).length; } function getActiveVideoProcessingCount(state) { return state.queue.filter( (item) => item.currentOperation === OperationType.TranscodeGif ).length; } function getPendingImageProcessing(state) { return state.queue.filter((item) => { const nextOperation = Array.isArray(item.operations?.[0]) ? item.operations[0][0] : item.operations?.[0]; return (nextOperation === OperationType.ResizeCrop || nextOperation === OperationType.Rotate) && item.currentOperation !== OperationType.ResizeCrop && item.currentOperation !== OperationType.Rotate; }); } function getPendingVideoProcessing(state) { return state.queue.filter((item) => { const nextOperation = Array.isArray(item.operations?.[0]) ? item.operations[0][0] : item.operations?.[0]; return nextOperation === OperationType.TranscodeGif && item.currentOperation !== OperationType.TranscodeGif; }); } function getFailedItems(state) { return state.queue.filter((item) => item.error !== void 0); } function hasPendingItemsByParentId(state, parentId) { return state.queue.some((item) => item.parentId === parentId); } function getItemProgress(state, id) { const item = state.queue.find((i) => i.id === id); return item?.progress; } export { getActiveImageProcessingCount, getActiveUploadCount, getActiveVideoProcessingCount, getAllItems, getBlobUrls, getFailedItems, getItem, getItemProgress, getPendingImageProcessing, getPendingUploads, getPendingVideoProcessing, hasPendingItemsByParentId, isBatchUploaded, isPaused }; //# sourceMappingURL=private-selectors.mjs.map