Fix url selectors

No memo required.
This commit is contained in:
infinite-persistence 2021-11-17 19:57:04 +08:00
parent 6382238834
commit 75bde149cf
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
4 changed files with 18 additions and 12 deletions

View file

@ -1,10 +1,10 @@
import { connect } from 'react-redux';
import { makeSelectCanonicalUrlForUri } from 'redux/selectors/claims';
import { selectCanonicalUrlForUri } from 'redux/selectors/claims';
import { doToast } from 'redux/actions/notifications';
import ClaimUri from './view';
const select = (state, props) => ({
shortUrl: makeSelectCanonicalUrlForUri(props.uri)(state),
shortUrl: selectCanonicalUrlForUri(state, props.uri),
});
export default connect(select, {

View file

@ -5,7 +5,7 @@ import {
selectFirstRunCompleted,
makeSelectNotificationsDisabled,
} from 'redux/selectors/subscriptions';
import { makeSelectPermanentUrlForUri } from 'redux/selectors/claims';
import { selectPermanentUrlForUri } from 'redux/selectors/claims';
import { selectUser } from 'redux/selectors/user';
import { doToast } from 'redux/actions/notifications';
import SubscribeButton from './view';
@ -13,7 +13,7 @@ import SubscribeButton from './view';
const select = (state, props) => ({
isSubscribed: selectIsSubscribedForUri(state, props.uri),
firstRunCompleted: selectFirstRunCompleted(state),
permanentUrl: makeSelectPermanentUrlForUri(props.uri)(state),
permanentUrl: selectPermanentUrlForUri(state, props.uri),
notificationsDisabled: makeSelectNotificationsDisabled(props.uri)(state),
user: selectUser(state),
});

View file

@ -1,6 +1,6 @@
import { connect } from 'react-redux';
import InvitedPage from './view';
import { makeSelectPermanentUrlForUri } from 'redux/selectors/claims';
import { selectPermanentUrlForUri } from 'redux/selectors/claims';
import { withRouter } from 'react-router';
const select = (state, props) => {
@ -10,7 +10,7 @@ const select = (state, props) => {
const sanitizedReferrer = referrer ? referrer.replace(':', '#') : '';
const uri = `lbry://${sanitizedReferrer}`;
return {
fullUri: makeSelectPermanentUrlForUri(uri)(state),
fullUri: selectPermanentUrlForUri(state, uri),
referrer: referrer,
};
};

View file

@ -647,14 +647,20 @@ export const selectClaimSearchByQueryLastPageReached = createSelector(
(state) => state.claimSearchByQueryLastPageReached || {}
);
export const makeSelectShortUrlForUri = (uri: string) =>
createSelector(makeSelectClaimForUri(uri), (claim) => claim && claim.short_url);
export const selectShortUrlForUri = (state: State, uri: string) => {
const claim = selectClaimForUri(state, uri);
return claim && claim.short_url;
};
export const makeSelectCanonicalUrlForUri = (uri: string) =>
createSelector(makeSelectClaimForUri(uri), (claim) => claim && claim.canonical_url);
export const selectCanonicalUrlForUri = (state: State, uri: string) => {
const claim = selectClaimForUri(state, uri);
return claim && claim.canonical_url;
};
export const makeSelectPermanentUrlForUri = (uri: string) =>
createSelector(makeSelectClaimForUri(uri), (claim) => claim && claim.permanent_url);
export const selectPermanentUrlForUri = (state: State, uri: string) => {
const claim = selectClaimForUri(state, uri);
return claim && claim.permanent_url;
};
export const makeSelectSupportsForUri = (uri: string) =>
createSelector(selectSupportsByOutpoint, makeSelectClaimForUri(uri), (byOutpoint, claim: ?StreamClaim) => {