Skip pending-channels loop if there are no pending channels.

This commit is contained in:
infinite-persistence 2021-12-02 21:36:53 +08:00
parent 8eff3dca21
commit afefd5f4f5
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -1,5 +1,10 @@
import { connect } from 'react-redux';
import { selectMyChannelUrls, selectFetchingMyChannels, makeSelectClaimIsPending } from 'redux/selectors/claims';
import {
selectMyChannelUrls,
selectFetchingMyChannels,
makeSelectClaimIsPending,
selectPendingIds,
} from 'redux/selectors/claims';
import { doFetchChannelListMine } from 'redux/actions/claims';
import { doSetActiveChannel } from 'redux/actions/app';
import { selectYoutubeChannels } from 'redux/selectors/user';
@ -7,8 +12,13 @@ import ChannelsPage from './view';
const select = (state) => {
const channelUrls = selectMyChannelUrls(state);
const pendingIds = selectPendingIds(state);
let pendingChannels = [];
if (channelUrls) {
if (channelUrls && pendingIds.length > 0) {
// TODO: should move this into a memoized selector, as this is a hot area.
// For now, I added a check to skip this loop when there are no pending
// channels, which is usually the case.
channelUrls.map((channelUrl) => {
const isPendingUrl = makeSelectClaimIsPending(channelUrl)(state);
if (isPendingUrl) pendingChannels.push(channelUrl);