From 4f9f62f999a6f87a16cd923f37bedf6d3865682f Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Fri, 10 May 2019 02:27:51 -0400 Subject: [PATCH] fix: address comments And resolve on edit + balance check --- src/ui/component/publishForm/view.jsx | 10 ++++++---- src/ui/redux/actions/file.js | 3 +-- src/ui/redux/actions/publish.js | 15 +++++++-------- src/ui/redux/reducers/publish.js | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/ui/component/publishForm/view.jsx b/src/ui/component/publishForm/view.jsx index 071ae74c1..3b2e21f39 100644 --- a/src/ui/component/publishForm/view.jsx +++ b/src/ui/component/publishForm/view.jsx @@ -71,10 +71,13 @@ class PublishForm extends React.PureComponent { } componentDidMount() { - const { thumbnail } = this.props; + const { thumbnail, name, channel, editingURI } = this.props; if (!thumbnail) { this.props.resetThumbnailStatus(); } + if (editingURI) { + this.getNewUri(name, channel); + } } getNewUri(name: string, channel: string) { @@ -156,7 +159,7 @@ class PublishForm extends React.PureComponent { let previousBidAmount = 0; if (myClaimForUri) { - previousBidAmount = myClaimForUri.amount; + previousBidAmount = Number(myClaimForUri.amount); } const totalAvailableBidAmount = previousBidAmount + balance; @@ -217,8 +220,7 @@ class PublishForm extends React.PureComponent { otherLicenseDescription, name: this.props.name || undefined, contentIsFree: this.props.contentIsFree, - feeAmount: this.props.fee.amount, - feeCurrency: this.props.fee.currency, + fee: this.props.fee, uri: this.props.uri || undefined, channel: this.props.channel, isStillEditing: this.props.isStillEditing, diff --git a/src/ui/redux/actions/file.js b/src/ui/redux/actions/file.js index 3061be269..8fb94aa06 100644 --- a/src/ui/redux/actions/file.js +++ b/src/ui/redux/actions/file.js @@ -33,8 +33,7 @@ export function doDeleteFile(outpoint, deleteFromComputer, abandonClaim) { // If the file is for a claim we published then also abandon the claim const myClaimsOutpoints = selectMyClaimsOutpoints(state); if (abandonClaim && myClaimsOutpoints.indexOf(outpoint) !== -1) { - const txid = outpoint.slice(0, -2); - const nout = Number(outpoint.slice(-1)); + const [txid, nout] = outpoint.split(':'); dispatch(doAbandonClaim(txid, nout)); } diff --git a/src/ui/redux/actions/publish.js b/src/ui/redux/actions/publish.js index 902f2b985..b943dbc0d 100644 --- a/src/ui/redux/actions/publish.js +++ b/src/ui/redux/actions/publish.js @@ -206,8 +206,7 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat channel, title, contentIsFree, - feeAmount, - feeCurrency, + fee, uri, nsfw, claim, @@ -234,7 +233,7 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat license, languages: [language], description, - tags: claim && claim.value.tags, + tags: (claim && claim.value.tags) || [], locations: claim && claim.value.locations, }; @@ -255,11 +254,11 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat } if (nsfw) { - if (publishPayload.tags && !publishPayload.tags.includes('mature')) { + if (!publishPayload.tags.includes('mature')) { publishPayload.tags.push('mature'); } } else { - const remove = publishPayload.tags && publishPayload.tags.indexOf('mature'); + const remove = publishPayload.tags.indexOf('mature'); if (remove > -1) { publishPayload.tags.splice(remove, 1); } @@ -269,9 +268,9 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat publishPayload.channel_id = channelId; } - if (!contentIsFree && (feeCurrency && Number(feeAmount) > 0)) { - publishPayload.fee_currency = feeCurrency; - publishPayload.fee_amount = creditsToString(feeAmount); + if (!contentIsFree && (fee.currency && Number(fee.amount) > 0)) { + publishPayload.fee_currency = fee.currency; + publishPayload.fee_amount = creditsToString(fee.amount); } // Only pass file on new uploads, not metadata only edits. diff --git a/src/ui/redux/reducers/publish.js b/src/ui/redux/reducers/publish.js index 43b70d66c..b49049361 100644 --- a/src/ui/redux/reducers/publish.js +++ b/src/ui/redux/reducers/publish.js @@ -9,7 +9,7 @@ type PublishState = { editingURI: ?string, filePath: ?string, contentIsFree: boolean, - price: { + fee: { amount: number, currency: string, }, @@ -33,7 +33,7 @@ const defaultState: PublishState = { editingURI: undefined, filePath: undefined, contentIsFree: true, - price: { + fee: { amount: 1, currency: 'LBC', },