Select pending url #369

Merged
jessopb merged 5 commits from selectPendingUrl into master 2020-12-16 16:19:51 +01:00
3 changed files with 44 additions and 14 deletions
Showing only changes of commit 4f57992762 - Show all commits

22
dist/bundle.es.js vendored
View file

@ -2461,13 +2461,25 @@ const selectPlayingUri = reselect.createSelector(selectState$1, state => state.p
const selectChannelClaimCounts = reselect.createSelector(selectState$1, state => state.channelClaimCounts || {});
const makeSelectPendingClaimUrlForName = name => reselect.createSelector(selectPendingIds, selectClaimsById, (pending, claims) => {
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 } = parseURI(claim.permanent_url);
return name === streamName;
const { streamName, channelName, isChannel } = parseURI(claim.permanent_url);
if (isChannel) {
return channelName === uriChannelName;
} else {
return streamName === uriStreamName;
}
});
return matchingClaim && matchingClaim.permanent_url;
return matchingClaim || null;
});
const makeSelectTotalItemsForChannel = uri => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri]);
@ -6242,7 +6254,7 @@ exports.makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel;
exports.makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris;
exports.makeSelectOmittedCountForChannel = makeSelectOmittedCountForChannel;
exports.makeSelectPendingAmountByUri = makeSelectPendingAmountByUri;
exports.makeSelectPendingClaimUrlForName = makeSelectPendingClaimUrlForName;
exports.makeSelectPendingClaimForUri = makeSelectPendingClaimForUri;
exports.makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri;
exports.makeSelectPublishFormValue = makeSelectPublishFormValue;
exports.makeSelectReflectingClaimForUri = makeSelectReflectingClaimForUri;

View file

@ -162,7 +162,7 @@ export {
makeSelectTagInClaimOrChannelForUri,
makeSelectContentTypeForUri,
makeSelectIsUriResolving,
makeSelectPendingClaimUrlForName,
makeSelectPendingClaimForUri,
makeSelectTotalItemsForChannel,
makeSelectTotalPagesForChannel,
makeSelectNsfwCountFromUris,

View file

@ -258,8 +258,8 @@ export const makeSelectMyPurchasesForPage = (query: ?string, page: number = 1) =
const end = Number(page) * Number(PAGE_SIZE);
return matchingFileInfos && matchingFileInfos.length
? matchingFileInfos
.slice(start, end)
.map(fileInfo => fileInfo.canonical_url || fileInfo.permanent_url)
.slice(start, end)
.map(fileInfo => fileInfo.canonical_url || fileInfo.permanent_url)
: [];
}
);
@ -365,8 +365,8 @@ export const makeSelectDateForUri = (uri: string) =>
(claim.value.release_time
? claim.value.release_time * 1000
: claim.meta && claim.meta.creation_timestamp
? claim.meta.creation_timestamp * 1000
: null);
? claim.meta.creation_timestamp * 1000
: null);
if (!timestamp) {
return undefined;
}
@ -563,17 +563,35 @@ export const selectChannelClaimCounts = createSelector(
state => state.channelClaimCounts || {}
);
export const makeSelectPendingClaimUrlForName = (name: string) =>
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 } = parseURI(claim.permanent_url);
return name === streamName;
const { streamName, channelName, isChannel } = parseURI(claim.permanent_url);
if (isChannel) {
return channelName === uriChannelName;
} else {
return streamName === uriStreamName;
}
});
return matchingClaim && matchingClaim.permanent_url;
return matchingClaim || null;
}
);