import dataSource from '../selectors/dataSource';
const updateFetchedDataFiles = function updateFetchedDataFiles(opts) {
  const {
    snapshot,
    set,
    values = [],
    oldStatusValues = []
  } = opts;
  values.forEach((val, i) => {
    const data = val ? {
      status: 'raw',
      value: val
    } : oldStatusValues[i];
    if (!data) return;
    const {
      config
    } = data.value;
    const atom = dataSource(config.key);
    if (snapshot) {
      snapshot.set(atom, data);
    }
    if (set) {
      set(atom, data);
    }
  });
};
export default updateFetchedDataFiles;