2017-12-21 22:08:54 +01:00
|
|
|
import { connect } from 'react-redux';
|
2018-04-18 06:03:01 +02:00
|
|
|
import {
|
|
|
|
doResolveUri,
|
|
|
|
makeSelectCostInfoForUri,
|
|
|
|
selectMyClaims,
|
|
|
|
selectClaimsByUri,
|
|
|
|
selectResolvingUris,
|
|
|
|
selectBalance,
|
|
|
|
} from 'lbry-redux';
|
2018-03-26 23:32:43 +02:00
|
|
|
import { doNavigate } from 'redux/actions/navigation';
|
|
|
|
import { selectPublishFormValues } from 'redux/selectors/publish';
|
2018-05-25 20:05:30 +02:00
|
|
|
import {
|
2018-04-02 15:53:29 +02:00
|
|
|
doResetThumbnailStatus,
|
2018-05-25 20:05:30 +02:00
|
|
|
doClearPublish,
|
|
|
|
doUpdatePublishForm,
|
|
|
|
doPublish,
|
|
|
|
doPrepareEdit,
|
|
|
|
} from 'redux/actions/publish';
|
2017-12-21 22:08:54 +01:00
|
|
|
import PublishPage from './view';
|
2017-05-02 10:21:00 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
const select = (state, props) => {
|
|
|
|
const publishState = selectPublishFormValues(state);
|
|
|
|
const { uri, name } = publishState;
|
|
|
|
|
|
|
|
const resolvingUris = selectResolvingUris(state);
|
|
|
|
let isResolvingUri = false;
|
|
|
|
if (uri) {
|
|
|
|
isResolvingUri = resolvingUris.includes(uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
const claimsByUri = selectClaimsByUri(state);
|
|
|
|
const myClaims = selectMyClaims(state);
|
|
|
|
|
|
|
|
const claimForUri = claimsByUri[uri];
|
|
|
|
let winningBidForClaimUri;
|
|
|
|
let myClaimForUri;
|
|
|
|
if (claimForUri) {
|
|
|
|
winningBidForClaimUri = claimForUri.effective_amount;
|
|
|
|
myClaimForUri = myClaims.find(claim => claim.name === name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
...publishState,
|
|
|
|
isResolvingUri,
|
|
|
|
claimForUri,
|
|
|
|
winningBidForClaimUri,
|
|
|
|
myClaimForUri,
|
|
|
|
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
|
|
|
balance: selectBalance(state),
|
|
|
|
};
|
|
|
|
};
|
2017-05-02 10:21:00 +02:00
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
const perform = dispatch => ({
|
2018-03-26 23:32:43 +02:00
|
|
|
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
|
|
|
|
clearPublish: () => dispatch(doClearPublish()),
|
2017-06-12 10:01:22 +02:00
|
|
|
resolveUri: uri => dispatch(doResolveUri(uri)),
|
2017-06-17 19:59:18 +02:00
|
|
|
publish: params => dispatch(doPublish(params)),
|
2018-03-26 23:32:43 +02:00
|
|
|
navigate: path => dispatch(doNavigate(path)),
|
2018-04-02 15:53:29 +02:00
|
|
|
prepareEdit: claim => dispatch(doPrepareEdit(claim)),
|
2018-04-02 15:55:36 +02:00
|
|
|
resetThumbnailStatus: () => dispatch(doResetThumbnailStatus()),
|
2017-06-06 06:21:55 +02:00
|
|
|
});
|
2017-05-02 10:21:00 +02:00
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
export default connect(select, perform)(PublishPage);
|