feat: add blocking + fixes #213
5 changed files with 69 additions and 27 deletions
44
dist/bundle.es.js
vendored
44
dist/bundle.es.js
vendored
|
@ -1673,16 +1673,12 @@ const makeSelectContentTypeForUri = uri => reselect.createSelector(makeSelectCla
|
|||
|
||||
const makeSelectThumbnailForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
|
||||
const thumbnail = claim && claim.value && claim.value.thumbnail;
|
||||
if (!thumbnail || !thumbnail.url) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return thumbnail.url.trim();
|
||||
return thumbnail && thumbnail.url ? thumbnail.url.trim() : undefined;
|
||||
});
|
||||
|
||||
const makeSelectCoverForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
|
||||
const cover = claim && claim.value && claim.value.cover;
|
||||
return cover ? cover.url : undefined;
|
||||
return cover && cover.url ? cover.url.trim() : undefined;
|
||||
});
|
||||
|
||||
const selectIsFetchingClaimListMine = reselect.createSelector(selectState$2, state => state.isFetchingClaimListMine);
|
||||
|
@ -2141,7 +2137,8 @@ function doSendTip(amount, claimId, isSupport, successCallback, errorCallback) {
|
|||
lbryProxy.support_create({
|
||||
claim_id: claimId,
|
||||
amount: creditsToString(amount),
|
||||
tip: !shouldSupport
|
||||
tip: !shouldSupport,
|
||||
blocking: true
|
||||
}).then(success, error);
|
||||
};
|
||||
}
|
||||
|
@ -2462,7 +2459,8 @@ function doCreateChannel(name, amount, optionalParams) {
|
|||
|
||||
const createParams = {
|
||||
name,
|
||||
bid: creditsToString(amount)
|
||||
bid: creditsToString(amount),
|
||||
blocking: true
|
||||
};
|
||||
|
||||
if (optionalParams) {
|
||||
|
@ -2508,10 +2506,14 @@ function doCreateChannel(name, amount, optionalParams) {
|
|||
}
|
||||
|
||||
function doUpdateChannel(params) {
|
||||
return dispatch => {
|
||||
return (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: UPDATE_CHANNEL_STARTED
|
||||
});
|
||||
const state = getState();
|
||||
const myChannels = selectMyChannelClaims(state);
|
||||
const channelClaim = myChannels.find(myChannel => myChannel.claim_id === params.claim_id);
|
||||
|
||||
const updateParams = {
|
||||
claim_id: params.claim_id,
|
||||
bid: creditsToString(params.amount),
|
||||
|
@ -2521,15 +2523,26 @@ function doUpdateChannel(params) {
|
|||
description: params.description,
|
||||
website_url: params.website,
|
||||
email: params.email,
|
||||
tags: [],
|
||||
replace: true,
|
||||
tags: []
|
||||
languages: [],
|
||||
locations: [],
|
||||
blocking: true
|
||||
};
|
||||
|
||||
if (params.tags) {
|
||||
updateParams.tags = params.tags.map(tag => tag.name);
|
||||
}
|
||||
|
||||
// TODO add languages and locations as above
|
||||
//we'll need to remove these once we add locations/channels to channel page edit/create options
|
||||
|
||||
if (channelClaim && channelClaim.value && channelClaim.value.locations) {
|
||||
updateParams.locations = channelClaim.value.locations;
|
||||
}
|
||||
|
||||
if (channelClaim && channelClaim.value && channelClaim.value.languages) {
|
||||
updateParams.languages = channelClaim.value.languages;
|
||||
}
|
||||
|
||||
return lbryProxy.channel_update(updateParams).then(result => {
|
||||
const channelClaim = result.outputs[0];
|
||||
|
@ -3253,11 +3266,12 @@ const doPublish = (success, fail) => (dispatch, getState) => {
|
|||
name,
|
||||
title,
|
||||
description,
|
||||
locations: locations,
|
||||
locations: [],
|
||||
bid: creditsToString(bid),
|
||||
languages: [language],
|
||||
tags: tags && tags.map(tag => tag.name),
|
||||
thumbnail_url: thumbnail
|
||||
thumbnail_url: thumbnail,
|
||||
blocking: true
|
||||
};
|
||||
// Temporary solution to keep the same publish flow with the new tags api
|
||||
// Eventually we will allow users to enter their own tags on publish
|
||||
|
@ -3288,6 +3302,10 @@ const doPublish = (success, fail) => (dispatch, getState) => {
|
|||
publishPayload.channel_id = channelId;
|
||||
}
|
||||
|
||||
if (myClaimForUri && myClaimForUri.value && myClaimForUri.value.locations) {
|
||||
publishPayload.locations = myClaimForUri.value.locations;
|
||||
}
|
||||
|
||||
if (!contentIsFree && fee && fee.currency && Number(fee.amount) > 0) {
|
||||
publishPayload.fee_currency = fee.currency;
|
||||
publishPayload.fee_amount = creditsToString(fee.amount);
|
||||
|
|
|
@ -3,7 +3,12 @@ import * as ACTIONS from 'constants/action_types';
|
|||
import Lbry from 'lbry';
|
||||
import { normalizeURI } from 'lbryURI';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
import { selectMyClaimsRaw, selectResolvingUris, selectClaimsByUri } from 'redux/selectors/claims';
|
||||
import {
|
||||
selectMyClaimsRaw,
|
||||
selectResolvingUris,
|
||||
selectClaimsByUri,
|
||||
selectMyChannelClaims,
|
||||
} from 'redux/selectors/claims';
|
||||
import { doFetchTransactions } from 'redux/actions/wallet';
|
||||
import { selectSupportsByOutpoint } from 'redux/selectors/wallet';
|
||||
import { creditsToString } from 'util/format-credits';
|
||||
|
@ -231,12 +236,13 @@ export function doCreateChannel(name: string, amount: number, optionalParams: an
|
|||
dispatch({
|
||||
type: ACTIONS.CREATE_CHANNEL_STARTED,
|
||||
});
|
||||
|
||||
|
||||
const createParams = {
|
||||
name,
|
||||
bid: creditsToString(amount),
|
||||
blocking: true,
|
||||
};
|
||||
|
||||
|
||||
if (optionalParams) {
|
||||
if (optionalParams.title) {
|
||||
createParams.title = optionalParams.title;
|
||||
|
@ -260,7 +266,7 @@ export function doCreateChannel(name: string, amount: number, optionalParams: an
|
|||
createParams.tags = optionalParams.tags.map(tag => tag.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
Lbry.channel_create(createParams)
|
||||
// outputs[0] is the certificate
|
||||
|
@ -283,10 +289,14 @@ export function doCreateChannel(name: string, amount: number, optionalParams: an
|
|||
}
|
||||
|
||||
export function doUpdateChannel(params: any) {
|
||||
return (dispatch: Dispatch) => {
|
||||
return (dispatch: Dispatch, getState: GetState) => {
|
||||
dispatch({
|
||||
type: ACTIONS.UPDATE_CHANNEL_STARTED,
|
||||
});
|
||||
const state = getState();
|
||||
const myChannels = selectMyChannelClaims(state);
|
||||
const channelClaim = myChannels.find(myChannel => myChannel.claim_id === params.claim_id);
|
||||
|
||||
const updateParams = {
|
||||
claim_id: params.claim_id,
|
||||
bid: creditsToString(params.amount),
|
||||
|
@ -296,15 +306,26 @@ export function doUpdateChannel(params: any) {
|
|||
description: params.description,
|
||||
website_url: params.website,
|
||||
email: params.email,
|
||||
replace: true,
|
||||
tags: [],
|
||||
replace: true,
|
||||
languages: [],
|
||||
locations: [],
|
||||
blocking: true,
|
||||
};
|
||||
|
||||
if (params.tags) {
|
||||
updateParams.tags = params.tags.map(tag => tag.name);
|
||||
}
|
||||
|
||||
// TODO add languages and locations as above
|
||||
//we'll need to remove these once we add locations/channels to channel page edit/create options
|
||||
|
||||
if (channelClaim && channelClaim.value && channelClaim.value.locations) {
|
||||
updateParams.locations = channelClaim.value.locations;
|
||||
}
|
||||
|
||||
if (channelClaim && channelClaim.value && channelClaim.value.languages) {
|
||||
updateParams.languages = channelClaim.value.languages;
|
||||
}
|
||||
|
||||
return Lbry.channel_update(updateParams)
|
||||
.then((result: ChannelUpdateResponse) => {
|
||||
|
|
|
@ -294,15 +294,17 @@ export const doPublish = (success: Function, fail: Function) => (
|
|||
languages?: Array<string>,
|
||||
tags: Array<string>,
|
||||
locations?: Array<any>,
|
||||
blocking: boolean,
|
||||
} = {
|
||||
name,
|
||||
title,
|
||||
description,
|
||||
locations: locations,
|
||||
locations: [],
|
||||
bid: creditsToString(bid),
|
||||
languages: [language],
|
||||
tags: tags && tags.map(tag => tag.name),
|
||||
thumbnail_url: thumbnail,
|
||||
blocking: true,
|
||||
};
|
||||
// Temporary solution to keep the same publish flow with the new tags api
|
||||
// Eventually we will allow users to enter their own tags on publish
|
||||
|
@ -333,6 +335,10 @@ export const doPublish = (success: Function, fail: Function) => (
|
|||
publishPayload.channel_id = channelId;
|
||||
}
|
||||
|
||||
if (myClaimForUri && myClaimForUri.value && myClaimForUri.value.locations) {
|
||||
publishPayload.locations = myClaimForUri.value.locations;
|
||||
}
|
||||
|
||||
if (!contentIsFree && fee && (fee.currency && Number(fee.amount) > 0)) {
|
||||
publishPayload.fee_currency = fee.currency;
|
||||
publishPayload.fee_amount = creditsToString(fee.amount);
|
||||
|
|
|
@ -252,6 +252,7 @@ export function doSendTip(amount, claimId, isSupport, successCallback, errorCall
|
|||
claim_id: claimId,
|
||||
amount: creditsToString(amount),
|
||||
tip: !shouldSupport,
|
||||
blocking: true,
|
||||
}).then(success, error);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -272,11 +272,7 @@ export const makeSelectThumbnailForUri = (uri: string) =>
|
|||
makeSelectClaimForUri(uri),
|
||||
claim => {
|
||||
const thumbnail = claim && claim.value && claim.value.thumbnail;
|
||||
if (!thumbnail || !thumbnail.url) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return thumbnail.url.trim();
|
||||
return thumbnail && thumbnail.url ? thumbnail.url.trim() : undefined;
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -285,7 +281,7 @@ export const makeSelectCoverForUri = (uri: string) =>
|
|||
makeSelectClaimForUri(uri),
|
||||
claim => {
|
||||
const cover = claim && claim.value && claim.value.cover;
|
||||
return cover ? cover.url : undefined;
|
||||
return cover && cover.url ? cover.url.trim() : undefined;
|
||||
}
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue