ca0cd2ca75
- 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. Co-authored-by: infinite-persistence <inf.persistence@gmail.com>
31 lines
1 KiB
JavaScript
31 lines
1 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import { selectMyChannelUrls, selectFetchingMyChannels, makeSelectClaimIsPending } from 'redux/selectors/claims';
|
|
import { doFetchChannelListMine } from 'redux/actions/claims';
|
|
import { doSetActiveChannel } from 'redux/actions/app';
|
|
import { selectYoutubeChannels } from 'redux/selectors/user';
|
|
import ChannelsPage from './view';
|
|
|
|
const select = (state) => {
|
|
const channelUrls = selectMyChannelUrls(state);
|
|
let pendingChannels = [];
|
|
if (channelUrls) {
|
|
channelUrls.map((channelUrl) => {
|
|
const isPendingUrl = makeSelectClaimIsPending(channelUrl)(state);
|
|
if (isPendingUrl) pendingChannels.push(channelUrl);
|
|
});
|
|
}
|
|
|
|
return {
|
|
channelUrls,
|
|
fetchingChannels: selectFetchingMyChannels(state),
|
|
youtubeChannels: selectYoutubeChannels(state),
|
|
pendingChannels,
|
|
};
|
|
};
|
|
|
|
const perform = (dispatch) => ({
|
|
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
|
|
doSetActiveChannel: (claimId) => dispatch(doSetActiveChannel(claimId)),
|
|
});
|
|
|
|
export default connect(select, perform)(ChannelsPage);
|