src/reducers/orderedReducer.js
function addDoc(array = [], action) {
  const { meta, payload } = action;
  if (!meta.subcollections || meta.storeAs) {
    return [
      ...array.slice(0, payload.ordered.newIndex),
      { id: meta.doc, ...payload.data },
      ...array.slice(payload.ordered.newIndex),
    ];
  }

  // Add doc to subcollection by modifying the existing doc at this level
  return modifyDoc(array, action);
}
function addDoc(array = [], action) {
  const { meta, payload } = action;
  if (!meta.subcollections || meta.storeAs) {
    return [
      ...array.slice(0, payload.ordered.newIndex),
      { id: meta.doc, ...payload.data },
      ...array.slice(payload.ordered.newIndex),
    ];
  }

  // Add doc to subcollection by modifying the existing doc at this level
  return modifyDoc(array, action);
}
function addDoc ( array = [ ] , action ) { const { meta , payload } = action ; if ( ! meta . subcollections || meta . storeAs ) { return [ ... array . slice ( 0 , payload . ordered . newIndex ) , { id : meta . doc , ... payload . data } , ... array . slice ( payload . ordered . newIndex ) , ] ; } // Add doc to subcollection by modifying the existing doc at this level return modifyDoc ( array , action ) ; }
Case reducer for adding a document to a collection or subcollection.
@param {Array} [array=[]] - Redux state of current collection
@param {Object} action - The action that was dispatched
@return {Array} State with document modified
Case reducer for adding a document to a collection or subcollection .