add optionalParams to doCreateChannel. Update myClaims after fetching channels #195
5 changed files with 126 additions and 16 deletions
67
dist/bundle.es.js
vendored
67
dist/bundle.es.js
vendored
|
@ -1790,6 +1790,10 @@ const makeSelectSupportsForUri = uri => reselect.createSelector(selectSupportsBy
|
||||||
return total;
|
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) {
|
function formatCredits(amount, precision, shortFormat = false) {
|
||||||
let actualAmount = parseFloat(amount),
|
let actualAmount = parseFloat(amount),
|
||||||
suffix = '';
|
suffix = '';
|
||||||
|
@ -2393,16 +2397,42 @@ function doFetchClaimsByChannel(uri, page = 1) {
|
||||||
};
|
};
|
||||||
I suppose it should. I'll also have to update this in I suppose it should. I'll also have to update this in `doUpdateChannel`.
|
|||||||
}
|
}
|
||||||
|
|
||||||
function doCreateChannel(name, amount) {
|
function doCreateChannel(name, amount, optionalParams) {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: CREATE_CHANNEL_STARTED
|
type: CREATE_CHANNEL_STARTED
|
||||||
});
|
});
|
||||||
|
|
||||||
return lbryProxy.channel_create({
|
const createParams = {
|
||||||
name,
|
name,
|
||||||
bid: creditsToString(amount)
|
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[0] is the certificate
|
||||||
// outputs[1] is the change from the tx, not in the app currently
|
// outputs[1] is the change from the tx, not in the app currently
|
||||||
.then(result => {
|
.then(result => {
|
||||||
|
@ -2429,8 +2459,8 @@ function doUpdateChannel(params) {
|
||||||
claim_id: params.claim_id,
|
claim_id: params.claim_id,
|
||||||
bid: creditsToString(params.amount),
|
bid: creditsToString(params.amount),
|
||||||
title: params.title,
|
title: params.title,
|
||||||
cover_url: params.cover,
|
cover_url: params.coverUrl,
|
||||||
thumbnail_url: params.thumbnail,
|
thumbnail_url: params.thumbnailUrl,
|
||||||
description: params.description,
|
description: params.description,
|
||||||
website_url: params.website,
|
website_url: params.website,
|
||||||
email: params.email,
|
email: params.email,
|
||||||
|
@ -3532,7 +3562,9 @@ const defaultState = {
|
||||||
claimSearchError: false,
|
claimSearchError: false,
|
||||||
claimSearchByQuery: {},
|
claimSearchByQuery: {},
|
||||||
claimSearchByQueryLastPageReached: {},
|
claimSearchByQueryLastPageReached: {},
|
||||||
fetchingClaimSearchByQuery: {}
|
fetchingClaimSearchByQuery: {},
|
||||||
|
updateChannelError: '',
|
||||||
|
updatingChannel: false
|
||||||
};
|
};
|
||||||
|
|
||||||
function handleClaimAction(state, action) {
|
function handleClaimAction(state, action) {
|
||||||
|
@ -3665,7 +3697,8 @@ reducers[FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => {
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
byId,
|
byId,
|
||||||
fetchingMyChannels: false,
|
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) => {
|
reducers[UPDATE_CHANNEL_COMPLETED] = (state, action) => {
|
||||||
const channelClaim = action.data.channelClaim;
|
const channelClaim = action.data.channelClaim;
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
|
@ -3770,7 +3810,16 @@ reducers[UPDATE_CHANNEL_COMPLETED] = (state, action) => {
|
||||||
byId[channelClaim.claim_id] = channelClaim;
|
byId[channelClaim.claim_id] = channelClaim;
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
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.selectTransactionListFilter = selectTransactionListFilter;
|
||||||
exports.selectTransactionsById = selectTransactionsById;
|
exports.selectTransactionsById = selectTransactionsById;
|
||||||
exports.selectUnfollowedTags = selectUnfollowedTags;
|
exports.selectUnfollowedTags = selectUnfollowedTags;
|
||||||
|
exports.selectUpdateChannelError = selectUpdateChannelError;
|
||||||
|
exports.selectUpdatingChannel = selectUpdatingChannel;
|
||||||
exports.selectUrisLoading = selectUrisLoading;
|
exports.selectUrisLoading = selectUrisLoading;
|
||||||
exports.selectWalletDecryptPending = selectWalletDecryptPending;
|
exports.selectWalletDecryptPending = selectWalletDecryptPending;
|
||||||
exports.selectWalletDecryptResult = selectWalletDecryptResult;
|
exports.selectWalletDecryptResult = selectWalletDecryptResult;
|
||||||
|
|
|
@ -200,6 +200,8 @@ export {
|
||||||
selectFetchingClaimSearchByQuery,
|
selectFetchingClaimSearchByQuery,
|
||||||
selectClaimSearchByQuery,
|
selectClaimSearchByQuery,
|
||||||
selectClaimSearchByQueryLastPageReached,
|
selectClaimSearchByQueryLastPageReached,
|
||||||
|
selectUpdatingChannel,
|
||||||
|
selectUpdateChannelError,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
|
|
||||||
export { makeSelectCommentsForUri } from 'redux/selectors/comments';
|
export { makeSelectCommentsForUri } from 'redux/selectors/comments';
|
||||||
|
|
|
@ -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) => {
|
return (dispatch: Dispatch) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.CREATE_CHANNEL_STARTED,
|
type: ACTIONS.CREATE_CHANNEL_STARTED,
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
const createParams = {
|
||||||
Lbry.channel_create({
|
|
||||||
name,
|
name,
|
||||||
bid: creditsToString(amount),
|
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(createParams)
|
||||||
// outputs[0] is the certificate
|
// outputs[0] is the certificate
|
||||||
// outputs[1] is the change from the tx, not in the app currently
|
// outputs[1] is the change from the tx, not in the app currently
|
||||||
.then((result: ChannelCreateResponse) => {
|
.then((result: ChannelCreateResponse) => {
|
||||||
|
@ -265,8 +291,8 @@ export function doUpdateChannel(params: any) {
|
||||||
claim_id: params.claim_id,
|
claim_id: params.claim_id,
|
||||||
bid: creditsToString(params.amount),
|
bid: creditsToString(params.amount),
|
||||||
title: params.title,
|
title: params.title,
|
||||||
cover_url: params.cover,
|
cover_url: params.coverUrl,
|
||||||
thumbnail_url: params.thumbnail,
|
thumbnail_url: params.thumbnailUrl,
|
||||||
description: params.description,
|
description: params.description,
|
||||||
website_url: params.website,
|
website_url: params.website,
|
||||||
email: params.email,
|
email: params.email,
|
||||||
|
|
|
@ -30,6 +30,8 @@ type State = {
|
||||||
[number]: Array<string>,
|
[number]: Array<string>,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
updateChannelError: string,
|
||||||
|
updatingChannel: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
const reducers = {};
|
const reducers = {};
|
||||||
|
@ -50,6 +52,8 @@ const defaultState = {
|
||||||
claimSearchByQuery: {},
|
claimSearchByQuery: {},
|
||||||
claimSearchByQueryLastPageReached: {},
|
claimSearchByQueryLastPageReached: {},
|
||||||
fetchingClaimSearchByQuery: {},
|
fetchingClaimSearchByQuery: {},
|
||||||
|
updateChannelError: '',
|
||||||
|
updatingChannel: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
function handleClaimAction(state: State, action: any): State {
|
function handleClaimAction(state: State, action: any): State {
|
||||||
|
@ -194,6 +198,7 @@ reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state: State, action: any): St
|
||||||
byId,
|
byId,
|
||||||
fetchingMyChannels: false,
|
fetchingMyChannels: false,
|
||||||
myChannelClaims,
|
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 => {
|
reducers[ACTIONS.UPDATE_CHANNEL_COMPLETED] = (state: State, action: any): State => {
|
||||||
const channelClaim: ChannelClaim = action.data.channelClaim;
|
const channelClaim: ChannelClaim = action.data.channelClaim;
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
|
@ -299,6 +311,15 @@ reducers[ACTIONS.UPDATE_CHANNEL_COMPLETED] = (state: State, action: any): State
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
byId,
|
byId,
|
||||||
|
updateChannelError: '',
|
||||||
|
updatingChannel: false,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
reducers[ACTIONS.UPDATE_CHANNEL_FAILED] = (state: State, action: any): State => {
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
updateChannelError: action.data.message,
|
||||||
|
updatingChannel: false,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -563,3 +563,13 @@ export const makeSelectSupportsForUri = (uri: string) =>
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const selectUpdatingChannel = createSelector(
|
||||||
|
selectState,
|
||||||
|
state => state.updatingChannel
|
||||||
|
);
|
||||||
|
|
||||||
|
export const selectUpdateChannelError = createSelector(
|
||||||
|
selectState,
|
||||||
|
state => state.updateChannelError
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in a new issue
Should this be called
coverUrl
to match the sdk value?