diff --git a/flow-typed/publish.js b/flow-typed/publish.js index 1de7a4b43..76266288b 100644 --- a/flow-typed/publish.js +++ b/flow-typed/publish.js @@ -3,8 +3,8 @@ declare type UpdatePublishFormData = { filePath?: string, contentIsFree?: boolean, - price?: { - amount: number, + fee?: { + amount: string, currency: string, }, title?: string, @@ -23,7 +23,7 @@ declare type UpdatePublishFormData = { licenseUrl?: string, licenseType?: string, uri?: string, - replace?: boolean, + nsfw: boolean, }; declare type PublishParams = { @@ -43,12 +43,11 @@ declare type PublishParams = { license: ?string, licenseUrl: ?string, fee?: { + amount: string, currency: string, - amount: number, }, - replace?: boolean, - - // This is bad. - // Will be removed for tags soon + feeCurrency: string, + feeAmount: string, + claim: StreamClaim, nsfw: boolean, }; diff --git a/package.json b/package.json index 00bd237da..4f21abd68 100644 --- a/package.json +++ b/package.json @@ -117,7 +117,7 @@ "jsmediatags": "^3.8.1", "json-loader": "^0.5.4", "lbry-format": "https://github.com/lbryio/lbry-format.git", - "lbry-redux": "lbryio/lbry-redux#32916b04e4888c06a9bb2b07c57ce6821a4acf1a", + "lbry-redux": "lbryio/lbry-redux#423123f1c19e61cead67c745d0892a2e4481cb6a", "lbryinc": "lbryio/lbryinc#43d382d9b74d396a581a74d87e4c53105e04f845", "lint-staged": "^7.0.2", "localforage": "^1.7.1", diff --git a/src/ui/component/publishForm/view.jsx b/src/ui/component/publishForm/view.jsx index 6c31cad3d..936088d82 100644 --- a/src/ui/component/publishForm/view.jsx +++ b/src/ui/component/publishForm/view.jsx @@ -28,7 +28,7 @@ type Props = { language: string, nsfw: boolean, contentIsFree: boolean, - price: { + fee: { amount: number, currency: string, }, @@ -217,10 +217,12 @@ class PublishForm extends React.PureComponent { otherLicenseDescription, name: this.props.name || undefined, contentIsFree: this.props.contentIsFree, - price: this.props.price, + feeAmount: this.props.fee.amount, + feeCurrency: this.props.fee.currency, uri: this.props.uri || undefined, channel: this.props.channel, isStillEditing: this.props.isStillEditing, + claim: this.props.myClaimForUri, }; publish(publishParams); @@ -292,7 +294,7 @@ class PublishForm extends React.PureComponent { language, nsfw, contentIsFree, - price, + fee, channel, name, updatePublishForm, @@ -440,11 +442,11 @@ class PublishForm extends React.PureComponent { updatePublishForm({ price: newPrice })} + price={fee} + onChange={newFee => updatePublishForm({ fee: newFee })} /> )} - {price.currency !== 'LBC' && ( + {fee.currency !== 'LBC' && (

{__( 'All content fees are charged in LBC. For non-LBC payment methods, the number of credits charged will be adjusted based on the value of LBRY credits at the time of purchase.' diff --git a/src/ui/modal/modalRemoveFile/index.js b/src/ui/modal/modalRemoveFile/index.js index 59d0cdb70..874671d21 100644 --- a/src/ui/modal/modalRemoveFile/index.js +++ b/src/ui/modal/modalRemoveFile/index.js @@ -1,6 +1,11 @@ import { connect } from 'react-redux'; import { doDeleteFileAndMaybeGoBack } from 'redux/actions/file'; -import { makeSelectTitleForUri, makeSelectClaimIsMine, makeSelectFileInfoForUri } from 'lbry-redux'; +import { + makeSelectTitleForUri, + makeSelectClaimIsMine, + makeSelectFileInfoForUri, + makeSelectClaimForUri, +} from 'lbry-redux'; import { doHideModal } from 'redux/actions/app'; import ModalRemoveFile from './view'; @@ -8,6 +13,7 @@ const select = (state, props) => ({ claimIsMine: makeSelectClaimIsMine(props.uri)(state), title: makeSelectTitleForUri(props.uri)(state), fileInfo: makeSelectFileInfoForUri(props.uri)(state), + claim: makeSelectClaimForUri(props.uri)(state), }); const perform = dispatch => ({ diff --git a/src/ui/modal/modalRemoveFile/view.jsx b/src/ui/modal/modalRemoveFile/view.jsx index 112387f96..e480b417d 100644 --- a/src/ui/modal/modalRemoveFile/view.jsx +++ b/src/ui/modal/modalRemoveFile/view.jsx @@ -4,6 +4,7 @@ import { Modal } from 'modal/modal'; import { FormField } from 'component/common/form'; type Props = { + claim: StreamClaim, claimIsMine: boolean, closeModal: () => void, deleteFile: (string, boolean, boolean) => void, @@ -45,10 +46,12 @@ class ModalRemoveFile extends React.PureComponent { } render() { - const { claimIsMine, closeModal, deleteFile, fileInfo, title } = this.props; + const { claim, claimIsMine, closeModal, deleteFile, fileInfo, title } = this.props; const { deleteChecked, abandonClaimChecked } = this.state; - const outpoint = fileInfo ? fileInfo.outpoint : ''; + const { txid, nout } = claim; + + const outpoint = fileInfo ? fileInfo.outpoint : `${txid}:${nout}`; return ( (dispatch: Dis contentIsFree: !fee.amount, author, description, - fee, + fee: { amount: fee.amount, currency: fee.currency }, languages, thumbnail: thumbnail ? thumbnail.url : null, title, uri, uploadThumbnailStatus: thumbnail ? THUMBNAIL_STATUSES.MANUAL : undefined, licenseUrl, - replace: true, }; + if (claim && isClaimNsfw(claim)) { + publishData.nsfw = true; + } else { + publishData.nsfw = false; + } + // Make sure custom liscence's are mapped properly // If the license isn't one of the standard licenses, map the custom license and description/url if (!CC_LICENSES.some(({ value }) => value === license)) { @@ -200,9 +206,11 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat channel, title, contentIsFree, - fee, + feeAmount, + feeCurrency, uri, nsfw, + claim, } = params; // get the claim id from the channel name, we will use that instead @@ -214,36 +222,56 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat channel_id?: string, bid: number, file_path?: string, - fee?: { amount: string, currency: string }, tags: Array, + locations?: Array, + license_url: string, + thumbnail_url: string, + release_time: number, } = { name, bid: creditsToString(bid), title, license, - license_url: licenseUrl, languages: [language], description, - thumbnail_url: thumbnail, - tags: [], + tags: claim.value.tags, + locations: claim.value.locations, }; // Temporary solution to keep the same publish flow with the new tags api // Eventually we will allow users to enter their own tags on publish // `nsfw` will probably be removed + + if (licenseUrl) { + publishPayload.license_url = licenseUrl; + } + + if (thumbnail) { + publishPayload.thumbnail_url = thumbnail; + } + + if (claim.value.release_time) { + publishPayload.release_time = Number(claim.value.release_time); + } + if (nsfw) { - publishPayload.tags.push('mature'); + if (!publishPayload.tags.includes('mature')) { + publishPayload.tags.push('mature'); + } + } else { + const remove = publishPayload.tags.indexOf('mature'); + if (remove > -1) { + publishPayload.tags.splice(remove, 1); + } } if (channelId) { publishPayload.channel_id = channelId; } - if (fee) { - publishPayload.fee = { - currency: fee.currency, - amount: creditsToString(fee.amount), - }; + if (!contentIsFree && (feeCurrency && Number(feeAmount) > 0)) { + publishPayload.fee_currency = feeCurrency; + publishPayload.fee_amount = creditsToString(feeAmount); } // Only pass file on new uploads, not metadata only edits. diff --git a/yarn.lock b/yarn.lock index 62f19613f..1c88b4d11 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6498,9 +6498,9 @@ lazy-val@^1.0.3, lazy-val@^1.0.4: yargs "^13.2.2" zstd-codec "^0.1.1" -lbry-redux@lbryio/lbry-redux#32916b04e4888c06a9bb2b07c57ce6821a4acf1a: +lbry-redux@lbryio/lbry-redux#423123f1c19e61cead67c745d0892a2e4481cb6a: version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/32916b04e4888c06a9bb2b07c57ce6821a4acf1a" + resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/423123f1c19e61cead67c745d0892a2e4481cb6a" dependencies: proxy-polyfill "0.1.6" reselect "^3.0.0" @@ -6696,7 +6696,7 @@ lodash-es@^4.17.11, lodash-es@^4.17.4, lodash-es@^4.2.1: resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.11.tgz#145ab4a7ac5c5e52a3531fb4f310255a152b4be0" integrity sha512-DHb1ub+rMjjrxqlB3H56/6MXtm1lSksDp2rA2cNWjG8mlDUYFhUj3Di2Zn5IwSU87xLv8tNIQ7sSwE/YOX/D/Q== -lodash.assign@^4.0.3, lodash.assign@^4.0.6, lodash.assign@^4.2.0: +lodash.assign@^4.0.3, lodash.assign@^4.0.6: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7" integrity sha1-DZnzzNem0mHRm9rrkkUAXShYCOc= @@ -6706,11 +6706,6 @@ lodash.camelcase@^4.3.0: resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" integrity sha1-soqmKIorn8ZRA1x3EfZathkDMaY= -lodash.clonedeep@^4.3.2: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" - integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8= - lodash.findkey@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.findkey/-/lodash.findkey-4.6.0.tgz#83058e903b51cbb759d09ccf546dea3ea39c4718" @@ -6746,11 +6741,6 @@ lodash.memoize@^4.1.2: resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= -lodash.mergewith@^4.6.0: - version "4.6.1" - resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz#639057e726c3afbdb3e7d42741caa8d6e4335927" - integrity sha512-eWw5r+PYICtEBgrBE5hhlT6aAa75f411bgDz/ZL2KZqYV03USvucsxcHUIlGTDTECs1eunpI7HOV7U+WLDvNdQ== - lodash.pickby@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.pickby/-/lodash.pickby-4.6.0.tgz#7dea21d8c18d7703a27c704c15d3b84a67e33aff" @@ -7375,7 +7365,7 @@ nan@2.12.1: resolved "https://registry.yarnpkg.com/nan/-/nan-2.12.1.tgz#7b1aa193e9aa86057e3c7bbd0ac448e770925552" integrity sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw== -nan@^2.10.0, nan@^2.9.2: +nan@^2.13.2, nan@^2.9.2: version "2.13.2" resolved "https://registry.yarnpkg.com/nan/-/nan-2.13.2.tgz#f51dc7ae66ba7d5d55e1e6d4d8092e802c9aefe7" integrity sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw== @@ -7556,9 +7546,9 @@ node-releases@^1.1.13: semver "^5.3.0" node-sass@^4.11.0: - version "4.11.0" - resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.11.0.tgz#183faec398e9cbe93ba43362e2768ca988a6369a" - integrity sha512-bHUdHTphgQJZaF1LASx0kAviPH7sGlcyNhWade4eVIpFp6tsn7SV8xNMTbsQFpEV9VXpnwTTnNYlfsZXgGgmkA== + version "4.12.0" + resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.12.0.tgz#0914f531932380114a30cc5fa4fa63233a25f017" + integrity sha512-A1Iv4oN+Iel6EPv77/HddXErL2a+gZ4uBeZUy+a8O35CFYTXhgA8MgLCWBtwpGZdCvTvQ9d+bQxX/QC36GDPpQ== dependencies: async-foreach "^0.1.3" chalk "^1.1.1" @@ -7567,12 +7557,10 @@ node-sass@^4.11.0: get-stdin "^4.0.1" glob "^7.0.3" in-publish "^2.0.0" - lodash.assign "^4.2.0" - lodash.clonedeep "^4.3.2" - lodash.mergewith "^4.6.0" + lodash "^4.17.11" meow "^3.7.0" mkdirp "^0.5.1" - nan "^2.10.0" + nan "^2.13.2" node-gyp "^3.8.0" npmlog "^4.0.0" request "^2.88.0"