fix: address comments

And resolve on edit + balance check
This commit is contained in:
Thomas Zarebczan 2019-05-10 02:27:51 -04:00
parent 319636df80
commit 4f9f62f999
4 changed files with 16 additions and 16 deletions

View file

@ -71,10 +71,13 @@ class PublishForm extends React.PureComponent<Props> {
} }
componentDidMount() { componentDidMount() {
const { thumbnail } = this.props; const { thumbnail, name, channel, editingURI } = this.props;
if (!thumbnail) { if (!thumbnail) {
this.props.resetThumbnailStatus(); this.props.resetThumbnailStatus();
} }
if (editingURI) {
this.getNewUri(name, channel);
}
} }
getNewUri(name: string, channel: string) { getNewUri(name: string, channel: string) {
@ -156,7 +159,7 @@ class PublishForm extends React.PureComponent<Props> {
let previousBidAmount = 0; let previousBidAmount = 0;
if (myClaimForUri) { if (myClaimForUri) {
previousBidAmount = myClaimForUri.amount; previousBidAmount = Number(myClaimForUri.amount);
} }
const totalAvailableBidAmount = previousBidAmount + balance; const totalAvailableBidAmount = previousBidAmount + balance;
@ -217,8 +220,7 @@ class PublishForm extends React.PureComponent<Props> {
otherLicenseDescription, otherLicenseDescription,
name: this.props.name || undefined, name: this.props.name || undefined,
contentIsFree: this.props.contentIsFree, contentIsFree: this.props.contentIsFree,
feeAmount: this.props.fee.amount, fee: this.props.fee,
feeCurrency: this.props.fee.currency,
uri: this.props.uri || undefined, uri: this.props.uri || undefined,
channel: this.props.channel, channel: this.props.channel,
isStillEditing: this.props.isStillEditing, isStillEditing: this.props.isStillEditing,

View file

@ -33,8 +33,7 @@ export function doDeleteFile(outpoint, deleteFromComputer, abandonClaim) {
// If the file is for a claim we published then also abandon the claim // If the file is for a claim we published then also abandon the claim
const myClaimsOutpoints = selectMyClaimsOutpoints(state); const myClaimsOutpoints = selectMyClaimsOutpoints(state);
if (abandonClaim && myClaimsOutpoints.indexOf(outpoint) !== -1) { if (abandonClaim && myClaimsOutpoints.indexOf(outpoint) !== -1) {
const txid = outpoint.slice(0, -2); const [txid, nout] = outpoint.split(':');
const nout = Number(outpoint.slice(-1));
dispatch(doAbandonClaim(txid, nout)); dispatch(doAbandonClaim(txid, nout));
} }

View file

@ -206,8 +206,7 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat
channel, channel,
title, title,
contentIsFree, contentIsFree,
feeAmount, fee,
feeCurrency,
uri, uri,
nsfw, nsfw,
claim, claim,
@ -234,7 +233,7 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat
license, license,
languages: [language], languages: [language],
description, description,
tags: claim && claim.value.tags, tags: (claim && claim.value.tags) || [],
locations: claim && claim.value.locations, locations: claim && claim.value.locations,
}; };
@ -255,11 +254,11 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat
} }
if (nsfw) { if (nsfw) {
if (publishPayload.tags && !publishPayload.tags.includes('mature')) { if (!publishPayload.tags.includes('mature')) {
publishPayload.tags.push('mature'); publishPayload.tags.push('mature');
} }
} else { } else {
const remove = publishPayload.tags && publishPayload.tags.indexOf('mature'); const remove = publishPayload.tags.indexOf('mature');
if (remove > -1) { if (remove > -1) {
publishPayload.tags.splice(remove, 1); publishPayload.tags.splice(remove, 1);
} }
@ -269,9 +268,9 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat
publishPayload.channel_id = channelId; publishPayload.channel_id = channelId;
} }
if (!contentIsFree && (feeCurrency && Number(feeAmount) > 0)) { if (!contentIsFree && (fee.currency && Number(fee.amount) > 0)) {
publishPayload.fee_currency = feeCurrency; publishPayload.fee_currency = fee.currency;
publishPayload.fee_amount = creditsToString(feeAmount); publishPayload.fee_amount = creditsToString(fee.amount);
} }
// Only pass file on new uploads, not metadata only edits. // Only pass file on new uploads, not metadata only edits.

View file

@ -9,7 +9,7 @@ type PublishState = {
editingURI: ?string, editingURI: ?string,
filePath: ?string, filePath: ?string,
contentIsFree: boolean, contentIsFree: boolean,
price: { fee: {
amount: number, amount: number,
currency: string, currency: string,
}, },
@ -33,7 +33,7 @@ const defaultState: PublishState = {
editingURI: undefined, editingURI: undefined,
filePath: undefined, filePath: undefined,
contentIsFree: true, contentIsFree: true,
price: { fee: {
amount: 1, amount: 1,
currency: 'LBC', currency: 'LBC',
}, },