diff --git a/ui/component/userChannelFollowIntro/index.js b/ui/component/userChannelFollowIntro/index.js index a16faf1bb..f11b71786 100644 --- a/ui/component/userChannelFollowIntro/index.js +++ b/ui/component/userChannelFollowIntro/index.js @@ -4,15 +4,17 @@ import { selectSubscriptions } from 'redux/selectors/subscriptions'; import { doChannelSubscribe } from 'redux/actions/subscriptions'; import UserChannelFollowIntro from './view'; import { selectHomepageData } from 'redux/selectors/settings'; +import { selectPrefsReady } from 'redux/selectors/sync'; -const select = state => ({ +const select = (state) => ({ followedTags: selectFollowedTags(state), subscribedChannels: selectSubscriptions(state), homepageData: selectHomepageData(state), + prefsReady: selectPrefsReady(state), }); -const perform = dispatch => ({ - channelSubscribe: uri => dispatch(doChannelSubscribe(uri)), +const perform = (dispatch) => ({ + channelSubscribe: (uri) => dispatch(doChannelSubscribe(uri)), }); export default connect(select, perform)(UserChannelFollowIntro); diff --git a/ui/component/userChannelFollowIntro/view.jsx b/ui/component/userChannelFollowIntro/view.jsx index c1555403b..8c1db7f68 100644 --- a/ui/component/userChannelFollowIntro/view.jsx +++ b/ui/component/userChannelFollowIntro/view.jsx @@ -14,28 +14,32 @@ type Props = { onBack: () => void, channelSubscribe: (sub: Subscription) => void, homepageData: any, + prefsReady: boolean, }; const channelsToSubscribe = AUTO_FOLLOW_CHANNELS.trim() .split(' ') - .filter(x => x !== ''); + .filter((x) => x !== ''); function UserChannelFollowIntro(props: Props) { - const { subscribedChannels, channelSubscribe, onContinue, onBack, homepageData } = props; + const { subscribedChannels, channelSubscribe, onContinue, onBack, homepageData, prefsReady } = props; const { PRIMARY_CONTENT_CHANNEL_IDS } = homepageData; const followingCount = (subscribedChannels && subscribedChannels.length) || 0; // subscribe to lbry useEffect(() => { - if (channelsToSubscribe && channelsToSubscribe.length) { - channelsToSubscribe.forEach(c => - channelSubscribe({ - channelName: parseURI(c).claimName, - uri: c, - }) - ); + if (channelsToSubscribe && channelsToSubscribe.length && prefsReady) { + const delayedChannelSubscribe = () => { + channelsToSubscribe.forEach((c) => + channelSubscribe({ + channelName: parseURI(c).claimName, + uri: c, + }) + ); + }; + setTimeout(delayedChannelSubscribe, 1000); } - }, []); + }, [prefsReady]); return (