diff --git a/dist/bundle.es.js b/dist/bundle.es.js index b68b4f0..0eb8aac 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1790,6 +1790,10 @@ const makeSelectSupportsForUri = uri => reselect.createSelector(selectSupportsBy return total; }); +const selectUpdatingChannel = reselect.createSelector(selectState$2, state => state.updatingChannel); + +const selectUpdateChannelError = reselect.createSelector(selectState$2, state => state.updateChannelError); + function formatCredits(amount, precision, shortFormat = false) { let actualAmount = parseFloat(amount), suffix = ''; @@ -2393,16 +2397,42 @@ function doFetchClaimsByChannel(uri, page = 1) { }; } -function doCreateChannel(name, amount) { +function doCreateChannel(name, amount, optionalParams) { return dispatch => { dispatch({ type: CREATE_CHANNEL_STARTED }); - return lbryProxy.channel_create({ + const createParams = { name, bid: creditsToString(amount) - }) + }; + + if (optionalParams) { + if (optionalParams.title) { + createParams.title = optionalParams.title; + } + if (optionalParams.coverUrl) { + createParams.cover_url = optionalParams.coverUrl; + } + if (optionalParams.thumbnailUrl) { + createParams.thumbnail_url = optionalParams.thumbnailUrl; + } + if (optionalParams.description) { + createParams.description = optionalParams.description; + } + if (optionalParams.website) { + createParams.website_url = optionalParams.website; + } + if (optionalParams.email) { + createParams.email = optionalParams.email; + } + if (optionalParams.tags) { + createParams.tags = optionalParams.tags.map(tag => tag.name); + } + } + + return lbryProxy.channel_create(createParams) // outputs[0] is the certificate // outputs[1] is the change from the tx, not in the app currently .then(result => { @@ -2429,8 +2459,8 @@ function doUpdateChannel(params) { claim_id: params.claim_id, bid: creditsToString(params.amount), title: params.title, - cover_url: params.cover, - thumbnail_url: params.thumbnail, + cover_url: params.coverUrl, + thumbnail_url: params.thumbnailUrl, description: params.description, website_url: params.website, email: params.email, @@ -3532,7 +3562,9 @@ const defaultState = { claimSearchError: false, claimSearchByQuery: {}, claimSearchByQueryLastPageReached: {}, - fetchingClaimSearchByQuery: {} + fetchingClaimSearchByQuery: {}, + updateChannelError: '', + updatingChannel: false }; function handleClaimAction(state, action) { @@ -3665,7 +3697,8 @@ reducers[FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => { return Object.assign({}, state, { byId, fetchingMyChannels: false, - myChannelClaims + myChannelClaims, + myClaims: claims }); }; @@ -3763,6 +3796,13 @@ reducers[CREATE_CHANNEL_COMPLETED] = (state, action) => { }); }; +reducers[UPDATE_CHANNEL_STARTED] = (state, action) => { + return Object.assign({}, state, { + updateChannelError: '', + updatingChannel: true + }); +}; + reducers[UPDATE_CHANNEL_COMPLETED] = (state, action) => { const channelClaim = action.data.channelClaim; const byId = Object.assign({}, state.byId); @@ -3770,7 +3810,16 @@ reducers[UPDATE_CHANNEL_COMPLETED] = (state, action) => { byId[channelClaim.claim_id] = channelClaim; return Object.assign({}, state, { - byId + byId, + updateChannelError: '', + updatingChannel: false + }); +}; + +reducers[UPDATE_CHANNEL_FAILED] = (state, action) => { + return Object.assign({}, state, { + updateChannelError: action.data.message, + updatingChannel: false }); }; @@ -5014,6 +5063,8 @@ exports.selectTransactionItems = selectTransactionItems; exports.selectTransactionListFilter = selectTransactionListFilter; exports.selectTransactionsById = selectTransactionsById; exports.selectUnfollowedTags = selectUnfollowedTags; +exports.selectUpdateChannelError = selectUpdateChannelError; +exports.selectUpdatingChannel = selectUpdatingChannel; exports.selectUrisLoading = selectUrisLoading; exports.selectWalletDecryptPending = selectWalletDecryptPending; exports.selectWalletDecryptResult = selectWalletDecryptResult; diff --git a/src/index.js b/src/index.js index fd11491..e77f9df 100644 --- a/src/index.js +++ b/src/index.js @@ -200,6 +200,8 @@ export { selectFetchingClaimSearchByQuery, selectClaimSearchByQuery, selectClaimSearchByQueryLastPageReached, + selectUpdatingChannel, + selectUpdateChannelError, } from 'redux/selectors/claims'; export { makeSelectCommentsForUri } from 'redux/selectors/comments'; diff --git a/src/redux/actions/claims.js b/src/redux/actions/claims.js index ab03679..c285e02 100644 --- a/src/redux/actions/claims.js +++ b/src/redux/actions/claims.js @@ -226,17 +226,43 @@ export function doFetchClaimsByChannel(uri: string, page: number = 1) { }; } -export function doCreateChannel(name: string, amount: number) { +export function doCreateChannel(name: string, amount: number, optionalParams: any) { return (dispatch: Dispatch) => { dispatch({ type: ACTIONS.CREATE_CHANNEL_STARTED, }); - + + const createParams = { + name, + bid: creditsToString(amount), + }; + + if (optionalParams) { + if (optionalParams.title) { + createParams.title = optionalParams.title; + } + if (optionalParams.coverUrl) { + createParams.cover_url = optionalParams.coverUrl; + } + if (optionalParams.thumbnailUrl) { + createParams.thumbnail_url = optionalParams.thumbnailUrl; + } + if (optionalParams.description) { + createParams.description = optionalParams.description; + } + if (optionalParams.website) { + createParams.website_url = optionalParams.website; + } + if (optionalParams.email) { + createParams.email = optionalParams.email; + } + if (optionalParams.tags) { + createParams.tags = optionalParams.tags.map(tag => tag.name); + } + } + return ( - Lbry.channel_create({ - name, - bid: creditsToString(amount), - }) + Lbry.channel_create(createParams) // outputs[0] is the certificate // outputs[1] is the change from the tx, not in the app currently .then((result: ChannelCreateResponse) => { @@ -265,8 +291,8 @@ export function doUpdateChannel(params: any) { claim_id: params.claim_id, bid: creditsToString(params.amount), title: params.title, - cover_url: params.cover, - thumbnail_url: params.thumbnail, + cover_url: params.coverUrl, + thumbnail_url: params.thumbnailUrl, description: params.description, website_url: params.website, email: params.email, diff --git a/src/redux/reducers/claims.js b/src/redux/reducers/claims.js index 337bfac..8c8d4d7 100644 --- a/src/redux/reducers/claims.js +++ b/src/redux/reducers/claims.js @@ -30,6 +30,8 @@ type State = { [number]: Array, }, }, + updateChannelError: string, + updatingChannel: boolean, }; const reducers = {}; @@ -50,6 +52,8 @@ const defaultState = { claimSearchByQuery: {}, claimSearchByQueryLastPageReached: {}, fetchingClaimSearchByQuery: {}, + updateChannelError: '', + updatingChannel: false, }; function handleClaimAction(state: State, action: any): State { @@ -194,6 +198,7 @@ reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state: State, action: any): St byId, fetchingMyChannels: false, myChannelClaims, + myClaims: claims, }); }; @@ -291,6 +296,13 @@ reducers[ACTIONS.CREATE_CHANNEL_COMPLETED] = (state: State, action: any): State }); }; +reducers[ACTIONS.UPDATE_CHANNEL_STARTED] = (state: State, action: any): State => { + return Object.assign({}, state, { + updateChannelError: '', + updatingChannel: true, + }); +}; + reducers[ACTIONS.UPDATE_CHANNEL_COMPLETED] = (state: State, action: any): State => { const channelClaim: ChannelClaim = action.data.channelClaim; const byId = Object.assign({}, state.byId); @@ -299,6 +311,15 @@ reducers[ACTIONS.UPDATE_CHANNEL_COMPLETED] = (state: State, action: any): State return Object.assign({}, state, { byId, + updateChannelError: '', + updatingChannel: false, + }); +}; + +reducers[ACTIONS.UPDATE_CHANNEL_FAILED] = (state: State, action: any): State => { + return Object.assign({}, state, { + updateChannelError: action.data.message, + updatingChannel: false, }); }; diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index b0c6a68..44fc310 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -563,3 +563,13 @@ export const makeSelectSupportsForUri = (uri: string) => return total; } ); + +export const selectUpdatingChannel = createSelector( + selectState, + state => state.updatingChannel +); + +export const selectUpdateChannelError = createSelector( + selectState, + state => state.updateChannelError +);