feat: add blocking + fixes #213

Merged
tzarebczan merged 1 commit from blocking-and-edits into master 2019-10-02 05:33:17 +02:00
5 changed files with 69 additions and 27 deletions

44
dist/bundle.es.js vendored
View file

@ -1673,16 +1673,12 @@ const makeSelectContentTypeForUri = uri => reselect.createSelector(makeSelectCla
const makeSelectThumbnailForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => { const makeSelectThumbnailForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
const thumbnail = claim && claim.value && claim.value.thumbnail; const thumbnail = claim && claim.value && claim.value.thumbnail;
if (!thumbnail || !thumbnail.url) { return thumbnail && thumbnail.url ? thumbnail.url.trim() : undefined;
return null;
}
return thumbnail.url.trim();
}); });
const makeSelectCoverForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => { const makeSelectCoverForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
const cover = claim && claim.value && claim.value.cover; 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); const selectIsFetchingClaimListMine = reselect.createSelector(selectState$2, state => state.isFetchingClaimListMine);
@ -2141,7 +2137,8 @@ function doSendTip(amount, claimId, isSupport, successCallback, errorCallback) {
lbryProxy.support_create({ lbryProxy.support_create({
claim_id: claimId, claim_id: claimId,
amount: creditsToString(amount), amount: creditsToString(amount),
tip: !shouldSupport tip: !shouldSupport,
blocking: true
}).then(success, error); }).then(success, error);
}; };
} }
@ -2462,7 +2459,8 @@ function doCreateChannel(name, amount, optionalParams) {
const createParams = { const createParams = {
name, name,
bid: creditsToString(amount) bid: creditsToString(amount),
blocking: true
}; };
if (optionalParams) { if (optionalParams) {
@ -2508,10 +2506,14 @@ function doCreateChannel(name, amount, optionalParams) {
} }
function doUpdateChannel(params) { function doUpdateChannel(params) {
return dispatch => { return (dispatch, getState) => {
dispatch({ dispatch({
type: UPDATE_CHANNEL_STARTED type: UPDATE_CHANNEL_STARTED
}); });
const state = getState();
const myChannels = selectMyChannelClaims(state);
const channelClaim = myChannels.find(myChannel => myChannel.claim_id === params.claim_id);
const updateParams = { const updateParams = {
claim_id: params.claim_id, claim_id: params.claim_id,
bid: creditsToString(params.amount), bid: creditsToString(params.amount),
@ -2521,15 +2523,26 @@ function doUpdateChannel(params) {
description: params.description, description: params.description,
website_url: params.website, website_url: params.website,
email: params.email, email: params.email,
tags: [],
replace: true, replace: true,
tags: [] languages: [],
locations: [],
blocking: true
}; };
if (params.tags) { if (params.tags) {
updateParams.tags = params.tags.map(tag => tag.name); 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 => { return lbryProxy.channel_update(updateParams).then(result => {
const channelClaim = result.outputs[0]; const channelClaim = result.outputs[0];
@ -3253,11 +3266,12 @@ const doPublish = (success, fail) => (dispatch, getState) => {
name, name,
title, title,
description, description,
locations: locations, locations: [],
bid: creditsToString(bid), bid: creditsToString(bid),
languages: [language], languages: [language],
tags: tags && tags.map(tag => tag.name), 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 // 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 // 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; 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) { if (!contentIsFree && fee && fee.currency && Number(fee.amount) > 0) {
publishPayload.fee_currency = fee.currency; publishPayload.fee_currency = fee.currency;
publishPayload.fee_amount = creditsToString(fee.amount); publishPayload.fee_amount = creditsToString(fee.amount);

View file

@ -3,7 +3,12 @@ import * as ACTIONS from 'constants/action_types';
import Lbry from 'lbry'; import Lbry from 'lbry';
import { normalizeURI } from 'lbryURI'; import { normalizeURI } from 'lbryURI';
import { doToast } from 'redux/actions/notifications'; 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 { doFetchTransactions } from 'redux/actions/wallet';
import { selectSupportsByOutpoint } from 'redux/selectors/wallet'; import { selectSupportsByOutpoint } from 'redux/selectors/wallet';
import { creditsToString } from 'util/format-credits'; import { creditsToString } from 'util/format-credits';
@ -231,12 +236,13 @@ export function doCreateChannel(name: string, amount: number, optionalParams: an
dispatch({ dispatch({
type: ACTIONS.CREATE_CHANNEL_STARTED, type: ACTIONS.CREATE_CHANNEL_STARTED,
}); });
const createParams = { const createParams = {
name, name,
bid: creditsToString(amount), bid: creditsToString(amount),
blocking: true,
}; };
if (optionalParams) { if (optionalParams) {
if (optionalParams.title) { if (optionalParams.title) {
createParams.title = 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); createParams.tags = optionalParams.tags.map(tag => tag.name);
} }
} }
return ( return (
Lbry.channel_create(createParams) Lbry.channel_create(createParams)
// outputs[0] is the certificate // outputs[0] is the certificate
@ -283,10 +289,14 @@ export function doCreateChannel(name: string, amount: number, optionalParams: an
} }
export function doUpdateChannel(params: any) { export function doUpdateChannel(params: any) {
return (dispatch: Dispatch) => { return (dispatch: Dispatch, getState: GetState) => {
dispatch({ dispatch({
type: ACTIONS.UPDATE_CHANNEL_STARTED, 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 = { const updateParams = {
claim_id: params.claim_id, claim_id: params.claim_id,
bid: creditsToString(params.amount), bid: creditsToString(params.amount),
@ -296,15 +306,26 @@ export function doUpdateChannel(params: any) {
description: params.description, description: params.description,
website_url: params.website, website_url: params.website,
email: params.email, email: params.email,
replace: true,
tags: [], tags: [],
replace: true,
languages: [],
locations: [],
blocking: true,
}; };
if (params.tags) { if (params.tags) {
updateParams.tags = params.tags.map(tag => tag.name); 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) return Lbry.channel_update(updateParams)
.then((result: ChannelUpdateResponse) => { .then((result: ChannelUpdateResponse) => {

View file

@ -294,15 +294,17 @@ export const doPublish = (success: Function, fail: Function) => (
languages?: Array<string>, languages?: Array<string>,
tags: Array<string>, tags: Array<string>,
locations?: Array<any>, locations?: Array<any>,
blocking: boolean,
} = { } = {
name, name,
title, title,
description, description,
locations: locations, locations: [],
bid: creditsToString(bid), bid: creditsToString(bid),
languages: [language], languages: [language],
tags: tags && tags.map(tag => tag.name), 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 // 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 // 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; 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)) { if (!contentIsFree && fee && (fee.currency && Number(fee.amount) > 0)) {
publishPayload.fee_currency = fee.currency; publishPayload.fee_currency = fee.currency;
publishPayload.fee_amount = creditsToString(fee.amount); publishPayload.fee_amount = creditsToString(fee.amount);

View file

@ -252,6 +252,7 @@ export function doSendTip(amount, claimId, isSupport, successCallback, errorCall
claim_id: claimId, claim_id: claimId,
amount: creditsToString(amount), amount: creditsToString(amount),
tip: !shouldSupport, tip: !shouldSupport,
blocking: true,
}).then(success, error); }).then(success, error);
}; };
} }

View file

@ -272,11 +272,7 @@ export const makeSelectThumbnailForUri = (uri: string) =>
makeSelectClaimForUri(uri), makeSelectClaimForUri(uri),
claim => { claim => {
const thumbnail = claim && claim.value && claim.value.thumbnail; const thumbnail = claim && claim.value && claim.value.thumbnail;
if (!thumbnail || !thumbnail.url) { return thumbnail && thumbnail.url ? thumbnail.url.trim() : undefined;
return null;
}
return thumbnail.url.trim();
} }
); );
@ -285,7 +281,7 @@ export const makeSelectCoverForUri = (uri: string) =>
makeSelectClaimForUri(uri), makeSelectClaimForUri(uri),
claim => { claim => {
const cover = claim && claim.value && claim.value.cover; const cover = claim && claim.value && claim.value.cover;
return cover ? cover.url : undefined; return cover && cover.url ? cover.url.trim() : undefined;
} }
); );