refactor DropZone mapStateToProps

This commit is contained in:
Travis Eden 2018-10-03 10:28:08 -04:00
parent 7f3e97d339
commit 48408a872d

View file

@ -3,17 +3,20 @@ import { selectFile, updateError, clearFile } from '../../actions/publish';
import { selectAsset } from '../../selectors/show'; import { selectAsset } from '../../selectors/show';
import View from './view'; import View from './view';
const mapStateToProps = ({ publish, show }) => { const mapStateToProps = ({ show, publish: { file, thumbnail, fileError, isUpdate } }) => {
const asset = selectAsset(show); const obj = { file, thumbnail, fileError, isUpdate };
const { name, claimData: { claimId, fileExt, outpoint } } = asset; let asset, name, claimId, fileExt, outpoint, sourceUrl;
const sourceUrl = `/${claimId}/${name}.${fileExt}?${outpoint}`; if (isUpdate) {
return { asset = selectAsset(show);
file : publish.file, if (asset) {
thumbnail: publish.thumbnail, ({name, claimData: {claimId, fileExt, outpoint}} = asset);
fileError: publish.error.file, sourceUrl = `/${claimId}/${name}.${fileExt}?${outpoint}`;
isUpdate : publish.isUpdate, }
sourceUrl, if (sourceUrl) {
}; obj.sourceUrl = sourceUrl;
}
}
return obj;
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = dispatch => {