Select pending url #369

Merged
jessopb merged 5 commits from selectPendingUrl into master 2020-12-16 16:19:51 +01:00
6 changed files with 94 additions and 2 deletions

38
dist/bundle.es.js vendored
View file

@ -2363,6 +2363,10 @@ const makeSelectAmountForUri = uri => reselect.createSelector(makeSelectClaimFor
return claim && claim.amount; return claim && claim.amount;
}); });
const makeSelectEffectiveAmountForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
return claim && claim.meta && typeof claim.meta.effective_amount === 'string' && Number(claim.meta.effective_amount);
});
const makeSelectContentTypeForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => { const makeSelectContentTypeForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
const source = claim && claim.value && claim.value.source; const source = claim && claim.value && claim.value.source;
return source ? source.media_type : undefined; return source ? source.media_type : undefined;
@ -2457,6 +2461,31 @@ const selectPlayingUri = reselect.createSelector(selectState$1, state => state.p
const selectChannelClaimCounts = reselect.createSelector(selectState$1, state => state.channelClaimCounts || {}); const selectChannelClaimCounts = reselect.createSelector(selectState$1, state => state.channelClaimCounts || {});
const makeSelectPendingClaimForUri = uri => reselect.createSelector(selectPendingIds, selectClaimsById, (pending, claims) => {
let uriIsChannel;
let uriStreamName;
let uriChannelName;
try {
({
isChannel: uriIsChannel,
streamName: uriStreamName,
channelName: uriChannelName
} = parseURI(uri));
} catch (e) {
return null;
}
const pendingClaims = pending.map(id => claims[id]);
const matchingClaim = pendingClaims.find(claim => {
const { streamName, channelName, isChannel } = parseURI(claim.permanent_url);
if (isChannel) {
return channelName === uriChannelName;
} else {
return streamName === uriStreamName;
}
});
return matchingClaim || null;
});
const makeSelectTotalItemsForChannel = uri => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri]); const makeSelectTotalItemsForChannel = uri => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri]);
const makeSelectTotalPagesForChannel = (uri, pageSize = 10) => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri] && Math.ceil(byUri[uri] / pageSize)); const makeSelectTotalPagesForChannel = (uri, pageSize = 10) => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri] && Math.ceil(byUri[uri] / pageSize));
@ -3684,6 +3713,12 @@ function doRepost(options) {
repostClaim repostClaim
} }
}); });
dispatch({
type: UPDATE_PENDING_CLAIMS,
data: {
claims: [repostClaim]
}
});
dispatch(doFetchClaimListMine(1, 10)); dispatch(doFetchClaimListMine(1, 10));
resolve(repostClaim); resolve(repostClaim);
@ -6203,6 +6238,7 @@ exports.makeSelectCoverForUri = makeSelectCoverForUri;
exports.makeSelectDateForUri = makeSelectDateForUri; exports.makeSelectDateForUri = makeSelectDateForUri;
exports.makeSelectDownloadPathForUri = makeSelectDownloadPathForUri; exports.makeSelectDownloadPathForUri = makeSelectDownloadPathForUri;
exports.makeSelectDownloadingForUri = makeSelectDownloadingForUri; exports.makeSelectDownloadingForUri = makeSelectDownloadingForUri;
exports.makeSelectEffectiveAmountForUri = makeSelectEffectiveAmountForUri;
exports.makeSelectFetchingChannelClaims = makeSelectFetchingChannelClaims; exports.makeSelectFetchingChannelClaims = makeSelectFetchingChannelClaims;
exports.makeSelectFileInfoForUri = makeSelectFileInfoForUri; exports.makeSelectFileInfoForUri = makeSelectFileInfoForUri;
exports.makeSelectFileNameForUri = makeSelectFileNameForUri; exports.makeSelectFileNameForUri = makeSelectFileNameForUri;
@ -6222,6 +6258,7 @@ exports.makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel;
exports.makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris; exports.makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris;
exports.makeSelectOmittedCountForChannel = makeSelectOmittedCountForChannel; exports.makeSelectOmittedCountForChannel = makeSelectOmittedCountForChannel;
exports.makeSelectPendingAmountByUri = makeSelectPendingAmountByUri; exports.makeSelectPendingAmountByUri = makeSelectPendingAmountByUri;
exports.makeSelectPendingClaimForUri = makeSelectPendingClaimForUri;
exports.makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri; exports.makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri;
exports.makeSelectPublishFormValue = makeSelectPublishFormValue; exports.makeSelectPublishFormValue = makeSelectPublishFormValue;
exports.makeSelectReflectingClaimForUri = makeSelectReflectingClaimForUri; exports.makeSelectReflectingClaimForUri = makeSelectReflectingClaimForUri;
@ -6313,6 +6350,7 @@ exports.selectMyClaimsWithoutChannels = selectMyClaimsWithoutChannels;
exports.selectMyPurchases = selectMyPurchases; exports.selectMyPurchases = selectMyPurchases;
exports.selectMyPurchasesCount = selectMyPurchasesCount; exports.selectMyPurchasesCount = selectMyPurchasesCount;
exports.selectMyStreamUrlsCount = selectMyStreamUrlsCount; exports.selectMyStreamUrlsCount = selectMyStreamUrlsCount;
exports.selectPendingIds = selectPendingIds;
exports.selectPendingSupportTransactions = selectPendingSupportTransactions; exports.selectPendingSupportTransactions = selectPendingSupportTransactions;
exports.selectPlayingUri = selectPlayingUri; exports.selectPlayingUri = selectPlayingUri;
exports.selectPublishFormValues = selectPublishFormValues; exports.selectPublishFormValues = selectPublishFormValues;

View file

@ -232,7 +232,7 @@ declare type StreamRepostOptions = {
name: string, name: string,
bid: string, bid: string,
claim_id: string, claim_id: string,
channel_id: string, channel_id?: string,
}; };
declare type StreamRepostResponse = GenericTxResponse; declare type StreamRepostResponse = GenericTxResponse;

2
flow-typed/Lbry.js vendored
View file

@ -232,7 +232,7 @@ declare type StreamRepostOptions = {
name: string, name: string,
bid: string, bid: string,
claim_id: string, claim_id: string,
channel_id: string, channel_id?: string,
}; };
declare type StreamRepostResponse = GenericTxResponse; declare type StreamRepostResponse = GenericTxResponse;

View file

@ -157,10 +157,12 @@ export {
makeSelectTitleForUri, makeSelectTitleForUri,
makeSelectDateForUri, makeSelectDateForUri,
makeSelectAmountForUri, makeSelectAmountForUri,
makeSelectEffectiveAmountForUri,
makeSelectTagsForUri, makeSelectTagsForUri,
makeSelectTagInClaimOrChannelForUri, makeSelectTagInClaimOrChannelForUri,
makeSelectContentTypeForUri, makeSelectContentTypeForUri,
makeSelectIsUriResolving, makeSelectIsUriResolving,
makeSelectPendingClaimForUri,
makeSelectTotalItemsForChannel, makeSelectTotalItemsForChannel,
makeSelectTotalPagesForChannel, makeSelectTotalPagesForChannel,
makeSelectNsfwCountFromUris, makeSelectNsfwCountFromUris,
@ -181,6 +183,7 @@ export {
makeSelectClaimWasPurchased, makeSelectClaimWasPurchased,
makeSelectAbandoningClaimById, makeSelectAbandoningClaimById,
makeSelectIsAbandoningClaimForUri, makeSelectIsAbandoningClaimForUri,
selectPendingIds,
selectReflectingById, selectReflectingById,
selectClaimsById, selectClaimsById,
selectClaimsByUri, selectClaimsByUri,

View file

@ -611,6 +611,12 @@ export function doRepost(options: StreamRepostOptions) {
repostClaim, repostClaim,
}, },
}); });
dispatch({
type: ACTIONS.UPDATE_PENDING_CLAIMS,
data: {
claims: [repostClaim],
},
});
dispatch(doFetchClaimListMine(1, 10)); dispatch(doFetchClaimListMine(1, 10));
resolve(repostClaim); resolve(repostClaim);

View file

@ -383,6 +383,19 @@ export const makeSelectAmountForUri = (uri: string) =>
} }
); );
export const makeSelectEffectiveAmountForUri = (uri: string) =>
createSelector(
makeSelectClaimForUri(uri),
claim => {
return (
claim &&
claim.meta &&
typeof claim.meta.effective_amount === 'string' &&
Number(claim.meta.effective_amount)
);
}
);
export const makeSelectContentTypeForUri = (uri: string) => export const makeSelectContentTypeForUri = (uri: string) =>
createSelector( createSelector(
makeSelectClaimForUri(uri), makeSelectClaimForUri(uri),
@ -555,6 +568,38 @@ export const selectChannelClaimCounts = createSelector(
state => state.channelClaimCounts || {} state => state.channelClaimCounts || {}
); );
export const makeSelectPendingClaimForUri = (uri: string) =>
createSelector(
selectPendingIds,
selectClaimsById,
(pending, claims) => {
let validUri;
let uriIsChannel;
let uriStreamName;
let uriChannelName;
try {
({
isChannel: uriIsChannel,
streamName: uriStreamName,
channelName: uriChannelName,
} = parseURI(uri));
validUri = true;
} catch (e) {
return null;
}
const pendingClaims = pending.map(id => claims[id]);
const matchingClaim = pendingClaims.find(claim => {
const { streamName, channelName, isChannel } = parseURI(claim.permanent_url);
if (isChannel) {
return channelName === uriChannelName;
} else {
return streamName === uriStreamName;
}
});
return matchingClaim || null;
}
);
export const makeSelectTotalItemsForChannel = (uri: string) => export const makeSelectTotalItemsForChannel = (uri: string) =>
createSelector( createSelector(
selectChannelClaimCounts, selectChannelClaimCounts,