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 { CHANNEL_NEW, CHANNEL_ANONYMOUS, MINIMUM_PUBLISH_BID } from 'constants/claim';
import * as icons from 'constants/icons';
import type { Claim } from 'types/claim';
import BidHelpText from './internal/bid-help-text';
import LicenseType from './internal/license-type';
@ -29,8 +30,6 @@ type Props = {
currency: string,
},
channel: string,
channelId: ?string,
myChannels: Array<{ name: string }>,
name: ?string,
tosAccepted: boolean,
updatePublishForm: UpdatePublishFormData => void,
@ -38,14 +37,7 @@ type Props = {
nameError: ?string,
isResolvingUri: boolean,
winningBidForClaimUri: number,
myClaimForUri: ?{
amount: number,
value: {
stream: {
source: { source: string },
},
},
},
myClaimForUri: ?Claim,
licenseType: string,
otherLicenseDescription: ?string,
licenseUrl: ?string,
@ -57,7 +49,7 @@ type Props = {
clearPublish: () => void,
resolveUri: string => void,
scrollToTop: () => void,
prepareEdit: ({}, uri) => void,
prepareEdit: ({}, string) => void,
};
class PublishForm extends React.PureComponent<Props> {
@ -139,10 +131,9 @@ class PublishForm extends React.PureComponent<Props> {
}
handleChannelChange(channelName: string) {
const { name, updatePublishForm, myChannels } = this.props;
const { name, updatePublishForm } = this.props;
const form = { channel: channelName };
const namedChannelClaim = myChannels.find(channel => channel.name === channelName);
form.channelId = namedChannelClaim ? namedChannelClaim.claim_id : '';
if (name) {
form.uri = this.getNewUri(name, channelName);
}
@ -186,7 +177,6 @@ class PublishForm extends React.PureComponent<Props> {
description,
language,
nsfw,
channelId,
licenseType,
licenseUrl,
otherLicenseDescription,
@ -196,6 +186,7 @@ class PublishForm extends React.PureComponent<Props> {
price,
uri,
myClaimForUri,
channel,
} = this.props;
let publishingLicense;
@ -220,7 +211,6 @@ class PublishForm extends React.PureComponent<Props> {
description,
language,
nsfw,
channelId,
license: publishingLicense,
licenseUrl: publishingLicenseUrl,
otherLicenseDescription,
@ -229,6 +219,7 @@ class PublishForm extends React.PureComponent<Props> {
contentIsFree,
price,
uri,
channel,
};
// Editing a claim
@ -303,7 +294,13 @@ class PublishForm extends React.PureComponent<Props> {
const formDisabled = (!filePath && !editingURI) || publishing;
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;
let submitLabel;
if (isStillEditing) {

View file

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

View file

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

View file

@ -1,5 +1,12 @@
// @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 type {
UpdatePublishFormData,
@ -73,6 +80,7 @@ export const doPrepareEdit = (claim: any, uri: string) => (dispatch: Dispatch) =
export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getState: () => {}) => {
const state = getState();
const myClaims = selectMyClaimsWithoutChannels(state);
const myChannels = selectMyChannelClaims(state);
const {
name,
@ -85,7 +93,6 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat
thumbnail,
nsfw,
channel,
channelId,
title,
contentIsFree,
price,
@ -93,6 +100,10 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat
sources,
} = 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;
const newPublishName = channel ? `${channel}/${name}` : name;
for (let i = 0; i < myClaims.length; i += 1) {