From bd3936fc2be14c89c559b6ea16e9c842acb73393 Mon Sep 17 00:00:00 2001 From: Travis Eden Date: Tue, 15 May 2018 19:01:53 -0400 Subject: [PATCH] publish by channel_id rather than channel_name --- src/renderer/component/publishForm/view.jsx | 17 ++++++++++------- src/renderer/page/publish/index.js | 2 ++ src/renderer/redux/actions/publish.js | 5 ++--- src/renderer/redux/reducers/publish.js | 4 ++++ 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/renderer/component/publishForm/view.jsx b/src/renderer/component/publishForm/view.jsx index ff3850a2c..e93ebb95d 100644 --- a/src/renderer/component/publishForm/view.jsx +++ b/src/renderer/component/publishForm/view.jsx @@ -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 { } 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 { description, language, nsfw, - channel, + channelId, licenseType, licenseUrl, otherLicenseDescription, @@ -217,7 +220,7 @@ class PublishForm extends React.PureComponent { description, language, nsfw, - channel, + channelId, license: publishingLicense, licenseUrl: publishingLicenseUrl, otherLicenseDescription, diff --git a/src/renderer/page/publish/index.js b/src/renderer/page/publish/index.js index 864ab0df5..78950abe7 100644 --- a/src/renderer/page/publish/index.js +++ b/src/renderer/page/publish/index.js @@ -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), }; diff --git a/src/renderer/redux/actions/publish.js b/src/renderer/redux/actions/publish.js index 2981299fc..270f156b4 100644 --- a/src/renderer/redux/actions/publish.js +++ b/src/renderer/redux/actions/publish.js @@ -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; @@ -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, }; diff --git a/src/renderer/redux/reducers/publish.js b/src/renderer/redux/reducers/publish.js index d20505598..048ca4ac5 100644 --- a/src/renderer/redux/reducers/publish.js +++ b/src/renderer/redux/reducers/publish.js @@ -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,