lbry-desktop/ui/component/repostCreate/index.js
infinite-persistence 0f1d4039a9
Use 'selectHasChannel' instead of the full 'selectMyChannelClaims'
- selectMyChannelClaims depends on `byId`, which currently is always invalidated per update, so it is not memoized.

- Most of the use-cases just needs the ID or the length of the array anyways, so avoid generating a Claim array (in selectMyChannelClaims) unnecessarily -- the client need to reduce it back down to IDs again :/

- The simpler boolean also removes the need to memoize the selector, which saves a bit of memory.
2021-11-08 15:02:44 +08:00

51 lines
1.9 KiB
JavaScript

import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app';
import {
makeSelectClaimForUri,
makeSelectTitleForUri,
selectRepostError,
selectRepostLoading,
selectMyClaimsWithoutChannels,
makeSelectEffectiveAmountForUri,
makeSelectIsUriResolving,
selectFetchingMyChannels,
} from 'redux/selectors/claims';
import { selectBalance } from 'redux/selectors/wallet';
import {
doRepost,
doClearRepostError,
doCheckPublishNameAvailability,
doCheckPendingClaims,
} from 'redux/actions/claims';
import { doToast } from 'redux/actions/notifications';
import { selectActiveChannelClaim, selectIncognito } from 'redux/selectors/app';
import RepostCreate from './view';
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
passedRepostClaim: makeSelectClaimForUri(props.name, false)(state),
passedRepostAmount: makeSelectEffectiveAmountForUri(props.name)(state),
enteredContentClaim: makeSelectClaimForUri(props.contentUri)(state),
enteredRepostClaim: makeSelectClaimForUri(props.repostUri, false)(state),
enteredRepostAmount: makeSelectEffectiveAmountForUri(props.repostUri)(state),
title: makeSelectTitleForUri(props.uri)(state),
balance: selectBalance(state),
error: selectRepostError(state),
reposting: selectRepostLoading(state),
myClaims: selectMyClaimsWithoutChannels(state),
isResolvingPassedRepost: props.name && makeSelectIsUriResolving(`lbry://${props.name}`)(state),
isResolvingEnteredRepost: props.repostUri && makeSelectIsUriResolving(`lbry://${props.repostUri}`)(state),
activeChannelClaim: selectActiveChannelClaim(state),
fetchingMyChannels: selectFetchingMyChannels(state),
incognito: selectIncognito(state),
});
export default connect(select, {
doHideModal,
doRepost,
doClearRepostError,
doToast,
doCheckPublishNameAvailability,
doCheckPendingClaims,
})(RepostCreate);