e35069de1c
## Issue One of the bottlenecks of livestream page. The component probably needs a re-design: - Don't perpetually mount -- only mount when activated by the user through "@". This would avoid the heavy processing entirely. - Better way of resolving uris (too many arrays, too many loops). - Tom also mentioned that we should not be resolving every commenter as we see encounter them in a livestream. This is currently the case because the component is always mounted. ## Changes Until the re-design occurs, attempt to cache the heavy processing. Also, trimmed down the amount of loops.
27 lines
1.2 KiB
JavaScript
27 lines
1.2 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import { MAX_LIVESTREAM_COMMENTS } from 'constants/livestream';
|
|
import { selectShowMatureContent } from 'redux/selectors/settings';
|
|
import { selectSubscriptionUris } from 'redux/selectors/subscriptions';
|
|
import { withRouter } from 'react-router';
|
|
import { selectCanonicalUrlForUri } from 'redux/selectors/claims';
|
|
import { doResolveUris } from 'redux/actions/claims';
|
|
import { selectChannelMentionData } from 'redux/selectors/livestream';
|
|
import ChannelMentionSuggestions from './view';
|
|
|
|
const select = (state, props) => {
|
|
const maxComments = props.isLivestream ? MAX_LIVESTREAM_COMMENTS : -1;
|
|
const data = selectChannelMentionData(state, props.uri, maxComments);
|
|
|
|
return {
|
|
commentorUris: data.commentorUris,
|
|
subscriptionUris: selectSubscriptionUris(state),
|
|
unresolvedCommentors: data.unresolvedCommentors,
|
|
unresolvedSubscriptions: data.unresolvedSubscriptions,
|
|
canonicalCreator: selectCanonicalUrlForUri(state, props.creatorUri),
|
|
canonicalCommentors: data.canonicalCommentors,
|
|
canonicalSubscriptions: data.canonicalSubscriptions,
|
|
showMature: selectShowMatureContent(state),
|
|
};
|
|
};
|
|
|
|
export default withRouter(connect(select, { doResolveUris })(ChannelMentionSuggestions));
|