mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
32 lines
992 B
JavaScript
32 lines
992 B
JavaScript
import { createSelector } from 'reselect';
|
|
import { parseURI } from 'lbry-redux';
|
|
|
|
const selectState = state => state.publish || {};
|
|
|
|
export const selectPendingPublishes = createSelector(
|
|
selectState,
|
|
state => state.pendingPublishes.map(pendingClaim => ({ ...pendingClaim, pending: true })) || []
|
|
);
|
|
|
|
export const selectPendingPublishesLessEdits = createSelector(
|
|
selectPendingPublishes,
|
|
pendingPublishes => pendingPublishes.filter(pendingPublish => !pendingPublish.isEdit)
|
|
);
|
|
|
|
export const selectPublishFormValues = createSelector(selectState, state => {
|
|
const { pendingPublish, ...formValues } = state;
|
|
return formValues;
|
|
});
|
|
|
|
export const selectPendingPublish = uri =>
|
|
createSelector(selectPendingPublishes, pendingPublishes => {
|
|
const { claimName, contentName } = parseURI(uri);
|
|
|
|
if (!pendingPublishes.length) {
|
|
return null;
|
|
}
|
|
|
|
return pendingPublishes.filter(
|
|
publish => publish.name === claimName || publish.name === contentName
|
|
)[0];
|
|
});
|