a3398843c2
Frequently used; top in perf profile Most of the time, you already have the claim object in the current context. `selectClaimIsMineForUri` will retrieve the claim again, which is wasteful, even if it is memoized (looking up the cache still takes time). Break apart the logic and added the alternative `selectClaimIsMine` for faster lookup. Co-authored-by: infinite-persistence <inf.persistence@gmail.com>
42 lines
1.6 KiB
JavaScript
42 lines
1.6 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import { PAGE_SIZE } from 'constants/claim';
|
|
import {
|
|
makeSelectClaimsInChannelForPage,
|
|
makeSelectFetchingChannelClaims,
|
|
selectClaimIsMine,
|
|
makeSelectTotalPagesInChannelSearch,
|
|
selectClaimForUri,
|
|
} from 'redux/selectors/claims';
|
|
import { doResolveUris } from 'redux/actions/claims';
|
|
import * as SETTINGS from 'constants/settings';
|
|
import { makeSelectChannelIsMuted } from 'redux/selectors/blocked';
|
|
import { withRouter } from 'react-router';
|
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
|
import { makeSelectClientSetting, selectShowMatureContent } from 'redux/selectors/settings';
|
|
|
|
import ChannelContent from './view';
|
|
|
|
const select = (state, props) => {
|
|
const { search } = props.location;
|
|
const urlParams = new URLSearchParams(search);
|
|
const page = urlParams.get('page') || 0;
|
|
const claim = props.uri && selectClaimForUri(state, props.uri);
|
|
|
|
return {
|
|
pageOfClaimsInChannel: makeSelectClaimsInChannelForPage(props.uri, page)(state),
|
|
fetching: makeSelectFetchingChannelClaims(props.uri)(state),
|
|
totalPages: makeSelectTotalPagesInChannelSearch(props.uri, PAGE_SIZE)(state),
|
|
channelIsMine: selectClaimIsMine(state, claim),
|
|
channelIsBlocked: makeSelectChannelIsMuted(props.uri)(state),
|
|
claim,
|
|
isAuthenticated: selectUserVerifiedEmail(state),
|
|
showMature: selectShowMatureContent(state),
|
|
tileLayout: makeSelectClientSetting(SETTINGS.TILE_LAYOUT)(state),
|
|
};
|
|
};
|
|
|
|
const perform = (dispatch) => ({
|
|
doResolveUris: (uris, returnCachedUris) => dispatch(doResolveUris(uris, returnCachedUris)),
|
|
});
|
|
|
|
export default withRouter(connect(select, perform)(ChannelContent));
|