UNPKG

@rpldy/uploader

Version:

the processing and queuing engine for react-uploady

35 lines (34 loc) 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getIsItemFinalized = exports.getIsItemExists = exports.finalizeItem = void 0; var _consts = require("../consts"); const finalizeItem = (queue, id, delItem = false) => { queue.updateState(state => { const { batchId } = state.items[id] || { batchId: null }; if (delItem) { delete state.items[id]; } const index = batchId ? state.itemQueue[batchId].indexOf(id) : -1; if (~index && batchId) { state.itemQueue[batchId].splice(index, 1); } const activeIndex = state.activeIds.indexOf(id); if (~activeIndex) { state.activeIds.splice(activeIndex, 1); } if (batchId && state.batches[batchId].itemBatchOptions[id]) { delete state.batches[batchId].itemBatchOptions[id]; } }); }; exports.finalizeItem = finalizeItem; const getIsItemExists = (queue, itemId) => !!queue.getState().items[itemId]; exports.getIsItemExists = getIsItemExists; const getIsItemFinalized = item => _consts.ITEM_FINALIZE_STATES.includes(item.state); exports.getIsItemFinalized = getIsItemFinalized;