Publish by channel_id #1481

Merged
daovist merged 1 commit from publish-by-channel-id into master 2018-05-25 17:05:56 +02:00
4 changed files with 18 additions and 10 deletions

View file

@ -29,6 +29,8 @@ type Props = {
currency: string,
},
channel: string,
channelId: ?string,
myChannels: Array<{ name: string }>,
name: ?string,
tosAccepted: boolean,
updatePublishForm: UpdatePublishFormData => void,
@ -137,13 +139,14 @@ class PublishForm extends React.PureComponent<Props> {
}
handleChannelChange(channelName: string) {
const { name, updatePublishForm } = this.props;
const { name, updatePublishForm, myChannels } = this.props;
const form = { channel: channelName };
const namedChannelClaim = myChannels.find(channel => channel.name === channelName);
form.channelId = namedChannelClaim ? namedChannelClaim.claim_id : '';
if (name) {
const uri = this.getNewUri(name, channelName);
updatePublishForm({ channel: channelName, uri });
} else {
updatePublishForm({ channel: channelName });
form.uri = this.getNewUri(name, channelName);
}
updatePublishForm(form);
}
handleBidChange(bid: number) {
@ -183,7 +186,7 @@ class PublishForm extends React.PureComponent<Props> {
description,
language,
nsfw,
channel,
channelId,
licenseType,
licenseUrl,
otherLicenseDescription,
@ -217,7 +220,7 @@ class PublishForm extends React.PureComponent<Props> {
description,
language,
nsfw,
channel,
channelId,
license: publishingLicense,
licenseUrl: publishingLicenseUrl,
otherLicenseDescription,

View file

@ -35,6 +35,7 @@ const select = (state, props) => {
const claimsByUri = selectClaimsByUri(state);
const myClaims = selectMyClaims(state);
const myChannels = selectMyChannelClaims(state);
const claimForUri = claimsByUri[uri];
let winningBidForClaimUri;
@ -50,6 +51,7 @@ const select = (state, props) => {
claimForUri,
winningBidForClaimUri,
myClaimForUri,
myChannels,
costInfo: makeSelectCostInfoForUri(props.uri)(state),
balance: selectBalance(state),
};

View file

@ -6,7 +6,6 @@ import type {
UpdatePublishFormAction,
PublishParams,
} from 'redux/reducers/publish';
import { CHANNEL_NEW, CHANNEL_ANONYMOUS } from 'constants/claim';
type Action = UpdatePublishFormAction | { type: ACTIONS.CLEAR_PUBLISH };
type PromiseAction = Promise<Action>;
@ -86,6 +85,7 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat
thumbnail,
nsfw,
channel,
channelId,
title,
contentIsFree,
price,
@ -104,7 +104,6 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat
}
}
const channelName = channel === CHANNEL_ANONYMOUS || channel === CHANNEL_NEW ? '' : channel;
const fee = contentIsFree || !price.amount ? undefined : { ...price };
const metadata = {
@ -126,7 +125,7 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat
const publishPayload = {
name,
channel_name: channelName,
channel_id: channelId,
bid,
metadata,
};

View file

@ -18,6 +18,7 @@ type PublishState = {
language: string,
tosAccepted: boolean,
channel: string,
channelId: ?string,
name: string,
nameError: ?string,
bid: number,
@ -41,6 +42,7 @@ export type UpdatePublishFormData = {
language?: string,
tosAccepted?: boolean,
channel?: string,
channelId?: string,
name?: string,
nameError?: string,
bid?: number,
@ -66,6 +68,7 @@ export type PublishParams = {
thumbnail: ?string,
nsfw: boolean,
channel: string,
channelId: string,
title: string,
contentIsFree: boolean,
uri: string,
@ -97,6 +100,7 @@ const defaultState: PublishState = {
language: 'en',
nsfw: false,
channel: CHANNEL_ANONYMOUS,
channelId: '',
tosAccepted: false,
name: '',
nameError: undefined,