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 View from './view';
const mapStateToProps = ({ publish, show }) => {
const asset = selectAsset(show);
const { name, claimData: { claimId, fileExt, outpoint } } = asset;
const sourceUrl = `/${claimId}/${name}.${fileExt}?${outpoint}`;
return {
file : publish.file,
thumbnail: publish.thumbnail,
fileError: publish.error.file,
isUpdate : publish.isUpdate,
sourceUrl,
};
const mapStateToProps = ({ show, publish: { file, thumbnail, fileError, isUpdate } }) => {
const obj = { file, thumbnail, fileError, isUpdate };
let asset, name, claimId, fileExt, outpoint, sourceUrl;
if (isUpdate) {
asset = selectAsset(show);
if (asset) {
({name, claimData: {claimId, fileExt, outpoint}} = asset);
sourceUrl = `/${claimId}/${name}.${fileExt}?${outpoint}`;
}
if (sourceUrl) {
obj.sourceUrl = sourceUrl;
}
}
return obj;
};
const mapDispatchToProps = dispatch => {