0f1d4039a9
- 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.
27 lines
1.2 KiB
JavaScript
27 lines
1.2 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import { doResolveUris } from 'redux/actions/claims';
|
|
import { makeSelectClaimIsMine, selectMyChannelClaimIds, makeSelectClaimForUri } from 'redux/selectors/claims';
|
|
import { selectIsFetchingCommentsByParentId, selectRepliesForParentId } from 'redux/selectors/comments';
|
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
|
import CommentsReplies from './view';
|
|
|
|
const select = (state, props) => {
|
|
const fetchedReplies = selectRepliesForParentId(state, props.parentId);
|
|
const resolvedReplies =
|
|
fetchedReplies && fetchedReplies.length > 0
|
|
? fetchedReplies.filter(({ channel_url }) => makeSelectClaimForUri(channel_url)(state) !== undefined)
|
|
: [];
|
|
|
|
return {
|
|
fetchedReplies,
|
|
resolvedReplies,
|
|
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
|
userCanComment: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
|
myChannelIds: selectMyChannelClaimIds(state),
|
|
isFetchingByParentId: selectIsFetchingCommentsByParentId(state),
|
|
};
|
|
};
|
|
|
|
const perform = (dispatch) => ({ doResolveUris: (uris) => dispatch(doResolveUris(uris, true)) });
|
|
|
|
export default connect(select, perform)(CommentsReplies);
|