Skip pending-channels loop if there are no pending channels.
This commit is contained in:
parent
8eff3dca21
commit
afefd5f4f5
1 changed files with 12 additions and 2 deletions
|
@ -1,5 +1,10 @@
|
||||||
import { connect } from 'react-redux';
|
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 { doFetchChannelListMine } from 'redux/actions/claims';
|
||||||
import { doSetActiveChannel } from 'redux/actions/app';
|
import { doSetActiveChannel } from 'redux/actions/app';
|
||||||
import { selectYoutubeChannels } from 'redux/selectors/user';
|
import { selectYoutubeChannels } from 'redux/selectors/user';
|
||||||
|
@ -7,8 +12,13 @@ import ChannelsPage from './view';
|
||||||
|
|
||||||
const select = (state) => {
|
const select = (state) => {
|
||||||
const channelUrls = selectMyChannelUrls(state);
|
const channelUrls = selectMyChannelUrls(state);
|
||||||
|
const pendingIds = selectPendingIds(state);
|
||||||
|
|
||||||
let pendingChannels = [];
|
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) => {
|
channelUrls.map((channelUrl) => {
|
||||||
const isPendingUrl = makeSelectClaimIsPending(channelUrl)(state);
|
const isPendingUrl = makeSelectClaimIsPending(channelUrl)(state);
|
||||||
if (isPendingUrl) pendingChannels.push(channelUrl);
|
if (isPendingUrl) pendingChannels.push(channelUrl);
|
||||||
|
|
Loading…
Reference in a new issue