autofollow waits for prefs ready
This commit is contained in:
parent
03eed6b961
commit
b10b79432f
2 changed files with 19 additions and 13 deletions
|
@ -4,15 +4,17 @@ import { selectSubscriptions } from 'redux/selectors/subscriptions';
|
||||||
import { doChannelSubscribe } from 'redux/actions/subscriptions';
|
import { doChannelSubscribe } from 'redux/actions/subscriptions';
|
||||||
import UserChannelFollowIntro from './view';
|
import UserChannelFollowIntro from './view';
|
||||||
import { selectHomepageData } from 'redux/selectors/settings';
|
import { selectHomepageData } from 'redux/selectors/settings';
|
||||||
|
import { selectPrefsReady } from 'redux/selectors/sync';
|
||||||
|
|
||||||
const select = state => ({
|
const select = (state) => ({
|
||||||
followedTags: selectFollowedTags(state),
|
followedTags: selectFollowedTags(state),
|
||||||
subscribedChannels: selectSubscriptions(state),
|
subscribedChannels: selectSubscriptions(state),
|
||||||
homepageData: selectHomepageData(state),
|
homepageData: selectHomepageData(state),
|
||||||
|
prefsReady: selectPrefsReady(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = (dispatch) => ({
|
||||||
channelSubscribe: uri => dispatch(doChannelSubscribe(uri)),
|
channelSubscribe: (uri) => dispatch(doChannelSubscribe(uri)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, perform)(UserChannelFollowIntro);
|
export default connect(select, perform)(UserChannelFollowIntro);
|
||||||
|
|
|
@ -14,28 +14,32 @@ type Props = {
|
||||||
onBack: () => void,
|
onBack: () => void,
|
||||||
channelSubscribe: (sub: Subscription) => void,
|
channelSubscribe: (sub: Subscription) => void,
|
||||||
homepageData: any,
|
homepageData: any,
|
||||||
|
prefsReady: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
const channelsToSubscribe = AUTO_FOLLOW_CHANNELS.trim()
|
const channelsToSubscribe = AUTO_FOLLOW_CHANNELS.trim()
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.filter(x => x !== '');
|
.filter((x) => x !== '');
|
||||||
|
|
||||||
function UserChannelFollowIntro(props: Props) {
|
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 { PRIMARY_CONTENT_CHANNEL_IDS } = homepageData;
|
||||||
const followingCount = (subscribedChannels && subscribedChannels.length) || 0;
|
const followingCount = (subscribedChannels && subscribedChannels.length) || 0;
|
||||||
|
|
||||||
// subscribe to lbry
|
// subscribe to lbry
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (channelsToSubscribe && channelsToSubscribe.length) {
|
if (channelsToSubscribe && channelsToSubscribe.length && prefsReady) {
|
||||||
channelsToSubscribe.forEach(c =>
|
const delayedChannelSubscribe = () => {
|
||||||
channelSubscribe({
|
channelsToSubscribe.forEach((c) =>
|
||||||
channelName: parseURI(c).claimName,
|
channelSubscribe({
|
||||||
uri: c,
|
channelName: parseURI(c).claimName,
|
||||||
})
|
uri: c,
|
||||||
);
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
setTimeout(delayedChannelSubscribe, 1000);
|
||||||
}
|
}
|
||||||
}, []);
|
}, [prefsReady]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
|
|
Loading…
Reference in a new issue