fix: edit with no file change

This commit is contained in:
Sean Yesmunt 2018-05-25 14:05:30 -04:00 committed by Sean Yesmunt
parent d35500de7e
commit f669714553
4 changed files with 33 additions and 38 deletions

View file

@ -10,6 +10,7 @@ import FileSelector from 'component/common/file-selector';
import { COPYRIGHT, OTHER } from 'constants/licenses'; import { COPYRIGHT, OTHER } from 'constants/licenses';
import { CHANNEL_NEW, CHANNEL_ANONYMOUS, MINIMUM_PUBLISH_BID } from 'constants/claim'; import { CHANNEL_NEW, CHANNEL_ANONYMOUS, MINIMUM_PUBLISH_BID } from 'constants/claim';
import * as icons from 'constants/icons'; import * as icons from 'constants/icons';
import type { Claim } from 'types/claim';
import BidHelpText from './internal/bid-help-text'; import BidHelpText from './internal/bid-help-text';
import LicenseType from './internal/license-type'; import LicenseType from './internal/license-type';
@ -29,8 +30,6 @@ type Props = {
currency: string, currency: string,
}, },
channel: string, channel: string,
channelId: ?string,
myChannels: Array<{ name: string }>,
name: ?string, name: ?string,
tosAccepted: boolean, tosAccepted: boolean,
updatePublishForm: UpdatePublishFormData => void, updatePublishForm: UpdatePublishFormData => void,
@ -38,14 +37,7 @@ type Props = {
nameError: ?string, nameError: ?string,
isResolvingUri: boolean, isResolvingUri: boolean,
winningBidForClaimUri: number, winningBidForClaimUri: number,
myClaimForUri: ?{ myClaimForUri: ?Claim,
amount: number,
value: {
stream: {
source: { source: string },
},
},
},
licenseType: string, licenseType: string,
otherLicenseDescription: ?string, otherLicenseDescription: ?string,
licenseUrl: ?string, licenseUrl: ?string,
@ -57,7 +49,7 @@ type Props = {
clearPublish: () => void, clearPublish: () => void,
resolveUri: string => void, resolveUri: string => void,
scrollToTop: () => void, scrollToTop: () => void,
prepareEdit: ({}, uri) => void, prepareEdit: ({}, string) => void,
}; };
class PublishForm extends React.PureComponent<Props> { class PublishForm extends React.PureComponent<Props> {
@ -139,10 +131,9 @@ class PublishForm extends React.PureComponent<Props> {
} }
handleChannelChange(channelName: string) { handleChannelChange(channelName: string) {
const { name, updatePublishForm, myChannels } = this.props; const { name, updatePublishForm } = this.props;
const form = { channel: channelName }; const form = { channel: channelName };
const namedChannelClaim = myChannels.find(channel => channel.name === channelName);
form.channelId = namedChannelClaim ? namedChannelClaim.claim_id : '';
if (name) { if (name) {
form.uri = this.getNewUri(name, channelName); form.uri = this.getNewUri(name, channelName);
} }
@ -186,7 +177,6 @@ class PublishForm extends React.PureComponent<Props> {
description, description,
language, language,
nsfw, nsfw,
channelId,
licenseType, licenseType,
licenseUrl, licenseUrl,
otherLicenseDescription, otherLicenseDescription,
@ -196,6 +186,7 @@ class PublishForm extends React.PureComponent<Props> {
price, price,
uri, uri,
myClaimForUri, myClaimForUri,
channel,
} = this.props; } = this.props;
let publishingLicense; let publishingLicense;
@ -220,7 +211,6 @@ class PublishForm extends React.PureComponent<Props> {
description, description,
language, language,
nsfw, nsfw,
channelId,
license: publishingLicense, license: publishingLicense,
licenseUrl: publishingLicenseUrl, licenseUrl: publishingLicenseUrl,
otherLicenseDescription, otherLicenseDescription,
@ -229,6 +219,7 @@ class PublishForm extends React.PureComponent<Props> {
contentIsFree, contentIsFree,
price, price,
uri, uri,
channel,
}; };
// Editing a claim // Editing a claim
@ -303,7 +294,13 @@ class PublishForm extends React.PureComponent<Props> {
const formDisabled = (!filePath && !editingURI) || publishing; const formDisabled = (!filePath && !editingURI) || publishing;
const formValid = this.checkIsFormValid(); const formValid = this.checkIsFormValid();
const simpleUri = uri && uri.split('#')[0]; // The user could be linked from lbry://@channel... or lbry://claim-name...
// If a channel exists, we need to make sure it is added to the uri for proper edit handling
// If this isn't an edit, just use the pregenerated uri
const simpleUri = myClaimForUri
? buildURI({ channelName: myClaimForUri.channel_name, contentName: myClaimForUri.name })
: uri;
const isStillEditing = editingURI === simpleUri; const isStillEditing = editingURI === simpleUri;
let submitLabel; let submitLabel;
if (isStillEditing) { if (isStillEditing) {

View file

@ -33,8 +33,6 @@ type Props = {
uri: string, uri: string,
rewardedContentClaimIds: Array<string>, rewardedContentClaimIds: Array<string>,
obscureNsfw: boolean, obscureNsfw: boolean,
playingUri: ?string,
isPaused: boolean,
claimIsMine: boolean, claimIsMine: boolean,
autoplay: boolean, autoplay: boolean,
costInfo: ?{}, costInfo: ?{},
@ -103,8 +101,6 @@ class FilePage extends React.Component<Props> {
uri, uri,
rewardedContentClaimIds, rewardedContentClaimIds,
obscureNsfw, obscureNsfw,
playingUri,
isPaused,
openModal, openModal,
claimIsMine, claimIsMine,
prepareEdit, prepareEdit,
@ -141,7 +137,6 @@ class FilePage extends React.Component<Props> {
editUri = buildURI({ channelName, contentName: claim.name }); editUri = buildURI({ channelName, contentName: claim.name });
} }
const isPlaying = playingUri === uri && !isPaused;
return ( return (
<Page extraPadding> <Page extraPadding>
{!claim || !metadata ? ( {!claim || !metadata ? (

View file

@ -1,26 +1,20 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doClaimRewardType } from 'redux/actions/rewards';
import { import {
doHistoryBack,
doResolveUri, doResolveUri,
makeSelectCostInfoForUri, makeSelectCostInfoForUri,
selectMyClaims, selectMyClaims,
selectFetchingMyChannels,
selectMyChannelClaims,
selectClaimsByUri, selectClaimsByUri,
selectResolvingUris, selectResolvingUris,
selectBalance, selectBalance,
} from 'lbry-redux'; } from 'lbry-redux';
import {
doFetchClaimListMine,
doFetchChannelListMine,
doCreateChannel,
} from 'redux/actions/content';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import rewards from 'rewards';
import { selectPublishFormValues } from 'redux/selectors/publish'; import { selectPublishFormValues } from 'redux/selectors/publish';
import { doClearPublish, doUpdatePublishForm, doPublish } from 'redux/actions/publish'; import {
import { doPrepareEdit } from 'redux/actions/publish'; doClearPublish,
doUpdatePublishForm,
doPublish,
doPrepareEdit,
} from 'redux/actions/publish';
import PublishPage from './view'; import PublishPage from './view';
const select = (state, props) => { const select = (state, props) => {
@ -35,7 +29,6 @@ const select = (state, props) => {
const claimsByUri = selectClaimsByUri(state); const claimsByUri = selectClaimsByUri(state);
const myClaims = selectMyClaims(state); const myClaims = selectMyClaims(state);
const myChannels = selectMyChannelClaims(state);
const claimForUri = claimsByUri[uri]; const claimForUri = claimsByUri[uri];
let winningBidForClaimUri; let winningBidForClaimUri;
@ -51,7 +44,6 @@ const select = (state, props) => {
claimForUri, claimForUri,
winningBidForClaimUri, winningBidForClaimUri,
myClaimForUri, myClaimForUri,
myChannels,
costInfo: makeSelectCostInfoForUri(props.uri)(state), costInfo: makeSelectCostInfoForUri(props.uri)(state),
balance: selectBalance(state), balance: selectBalance(state),
}; };

View file

@ -1,5 +1,12 @@
// @flow // @flow
import { ACTIONS, Lbry, selectMyClaimsWithoutChannels, doNotify, MODALS } from 'lbry-redux'; import {
ACTIONS,
Lbry,
selectMyClaimsWithoutChannels,
doNotify,
MODALS,
selectMyChannelClaims,
} from 'lbry-redux';
import { selectPendingPublishes } from 'redux/selectors/publish'; import { selectPendingPublishes } from 'redux/selectors/publish';
import type { import type {
UpdatePublishFormData, UpdatePublishFormData,
@ -73,6 +80,7 @@ export const doPrepareEdit = (claim: any, uri: string) => (dispatch: Dispatch) =
export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getState: () => {}) => { export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getState: () => {}) => {
const state = getState(); const state = getState();
const myClaims = selectMyClaimsWithoutChannels(state); const myClaims = selectMyClaimsWithoutChannels(state);
const myChannels = selectMyChannelClaims(state);
const { const {
name, name,
@ -85,7 +93,6 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat
thumbnail, thumbnail,
nsfw, nsfw,
channel, channel,
channelId,
title, title,
contentIsFree, contentIsFree,
price, price,
@ -93,6 +100,10 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat
sources, sources,
} = params; } = params;
// get the claim id from the channel name, we will use that instead
const namedChannelClaim = myChannels.find(myChannel => myChannel.name === channel);
const channelId = namedChannelClaim ? namedChannelClaim.claim_id : '';
let isEdit; let isEdit;
const newPublishName = channel ? `${channel}/${name}` : name; const newPublishName = channel ? `${channel}/${name}` : name;
for (let i = 0; i < myClaims.length; i += 1) { for (let i = 0; i < myClaims.length; i += 1) {