refactor DropZone mapStateToProps
This commit is contained in:
parent
7f3e97d339
commit
48408a872d
1 changed files with 14 additions and 11 deletions
|
@ -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 => {
|
||||
|
|
Loading…
Reference in a new issue