moar release

Fixes claim editing while keeping any existing tags + setting/clearing fee.
Fixes not being able to abandon claims if file was deleted

Beware of lint errors..some old and new. Everything works and we should clean them up later once tags are properly integrated.
This commit is contained in:
Thomas Zarebczan 2019-05-09 19:26:03 -04:00
parent aa9ef09a9d
commit 3d27b4f2d9
8 changed files with 82 additions and 61 deletions

15
flow-typed/publish.js vendored
View file

@ -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,
};

View file

@ -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",

View file

@ -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<Props> {
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<Props> {
language,
nsfw,
contentIsFree,
price,
fee,
channel,
name,
updatePublishForm,
@ -440,11 +442,11 @@ class PublishForm extends React.PureComponent<Props> {
<FormFieldPrice
name="content_cost_amount"
min="0"
price={price}
onChange={newPrice => updatePublishForm({ price: newPrice })}
price={fee}
onChange={newFee => updatePublishForm({ fee: newFee })}
/>
)}
{price.currency !== 'LBC' && (
{fee.currency !== 'LBC' && (
<p className="form-field__help">
{__(
'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.'

View file

@ -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 => ({

View file

@ -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<Props, State> {
}
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 (
<Modal
isOpen

View file

@ -2,7 +2,7 @@ import * as ACTIONS from 'constants/action_types';
// @if TARGET='app'
import { shell } from 'electron';
// @endif
import { Lbry, batchActions, doAbandonClaim, selectMyClaimsOutpoints, selectFileInfosByOutpoint } from 'lbry-redux';
import { Lbry, batchActions, doAbandonClaim, selectMyClaimsOutpoints } from 'lbry-redux';
import { doHideModal } from 'redux/actions/app';
import { goBack } from 'connected-react-router';
@ -33,15 +33,10 @@ 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 byOutpoint = selectFileInfosByOutpoint(state);
const fileInfo = byOutpoint[outpoint];
const txid = outpoint.slice(0, -2);
const nout = Number(outpoint.slice(-1));
if (fileInfo) {
const txid = fileInfo.outpoint.slice(0, -2);
const nout = Number(fileInfo.outpoint.slice(-1));
dispatch(doAbandonClaim(txid, nout));
}
dispatch(doAbandonClaim(txid, nout));
}
dispatch({

View file

@ -11,6 +11,7 @@ import {
selectPendingById,
selectMyClaimsWithoutChannels,
doError,
isClaimNsfw,
} from 'lbry-redux';
import { doOpenModal } from 'redux/actions/app';
import { selectosNotificationsEnabled } from 'redux/selectors/settings';
@ -152,16 +153,21 @@ export const doPrepareEdit = (claim: StreamClaim, uri: string) => (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<string>,
locations?: Array<Location>,
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.

View file

@ -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"