Cache subscription uris if we're gonna map it often.

This commit is contained in:
infinite-persistence 2021-11-17 16:18:00 +08:00
parent 91f1f588e6
commit 6b6879ba64
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
2 changed files with 7 additions and 2 deletions

View file

@ -1,7 +1,7 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { MAX_LIVESTREAM_COMMENTS } from 'constants/livestream'; import { MAX_LIVESTREAM_COMMENTS } from 'constants/livestream';
import { selectShowMatureContent } from 'redux/selectors/settings'; import { selectShowMatureContent } from 'redux/selectors/settings';
import { selectSubscriptions } from 'redux/selectors/subscriptions'; import { selectSubscriptionUris } from 'redux/selectors/subscriptions';
import { withRouter } from 'react-router'; import { withRouter } from 'react-router';
import { makeSelectClaimForUri } from 'redux/selectors/claims'; import { makeSelectClaimForUri } from 'redux/selectors/claims';
import { doResolveUris } from 'redux/actions/claims'; import { doResolveUris } from 'redux/actions/claims';
@ -9,7 +9,7 @@ import { selectTopLevelCommentsForUri } from 'redux/selectors/comments';
import ChannelMentionSuggestions from './view'; import ChannelMentionSuggestions from './view';
const select = (state, props) => { const select = (state, props) => {
const subscriptionUris = selectSubscriptions(state).map(({ uri }) => uri); const subscriptionUris = selectSubscriptionUris(state);
const topLevelComments = selectTopLevelCommentsForUri( const topLevelComments = selectTopLevelCommentsForUri(
state, state,
props.uri, props.uri,

View file

@ -20,6 +20,11 @@ export const selectSubscriptions = createSelector(
(state) => state.subscriptions && state.subscriptions.sort((a, b) => a.channelName.localeCompare(b.channelName)) (state) => state.subscriptions && state.subscriptions.sort((a, b) => a.channelName.localeCompare(b.channelName))
); );
export const selectSubscriptionUris = createSelector(
selectSubscriptions,
(subscriptions) => subscriptions && subscriptions.map((sub) => sub.uri)
);
export const selectFollowing = createSelector(selectState, (state) => state.following && state.following); export const selectFollowing = createSelector(selectState, (state) => state.following && state.following);
// Fetching list of users subscriptions // Fetching list of users subscriptions