Automatically set default channel on sign up (#1559)

This commit is contained in:
saltrafael 2022-05-24 07:18:26 -03:00 committed by GitHub
parent 3918906605
commit f9d1b8de8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 8 deletions

View file

@ -18,10 +18,15 @@ import {
import { selectUnclaimedRewards } from 'redux/selectors/rewards';
import { doFetchChannelListMine, doFetchCollectionListMine } from 'redux/actions/claims';
import { selectMyChannelClaimIds } from 'redux/selectors/claims';
import { selectLanguage, selectLoadedLanguages, selectThemePath } from 'redux/selectors/settings';
import {
selectLanguage,
selectLoadedLanguages,
selectThemePath,
selectDefaultChannelClaim,
} from 'redux/selectors/settings';
import { selectModal, selectActiveChannelClaim, selectIsReloadRequired } from 'redux/selectors/app';
import { selectUploadCount } from 'redux/selectors/publish';
import { doOpenAnnouncements, doSetLanguage } from 'redux/actions/settings';
import { doOpenAnnouncements, doSetLanguage, doSetDefaultChannel } from 'redux/actions/settings';
import { doSyncLoop } from 'redux/actions/sync';
import { doSignIn, doSetIncognito } from 'redux/actions/app';
import { doFetchModBlockedList, doFetchCommentModAmIList } from 'redux/actions/comments';
@ -46,6 +51,7 @@ const select = (state) => ({
myChannelClaimIds: selectMyChannelClaimIds(state),
hasPremiumPlus: selectOdyseeMembershipIsPremiumPlus(state),
homepageFetched: selectHomepageFetched(state),
defaultChannelClaim: selectDefaultChannelClaim(state),
});
const perform = {
@ -60,6 +66,7 @@ const perform = {
fetchModAmIList: doFetchCommentModAmIList,
doOpenAnnouncements,
doSetLastViewedAnnouncement,
doSetDefaultChannel,
};
export default hot(connect(select, perform)(App));

View file

@ -88,8 +88,10 @@ type Props = {
fetchModBlockedList: () => void,
fetchModAmIList: () => void,
homepageFetched: boolean,
defaultChannelClaim: ?any,
doOpenAnnouncements: () => void,
doSetLastViewedAnnouncement: (hash: string) => void,
doSetDefaultChannel: (claimId: string) => void,
};
function App(props: Props) {
@ -123,8 +125,10 @@ function App(props: Props) {
hasPremiumPlus,
fetchModAmIList,
homepageFetched,
defaultChannelClaim,
doOpenAnnouncements,
doSetLastViewedAnnouncement,
doSetDefaultChannel,
} = props;
const isMobile = useIsMobile();
@ -339,6 +343,7 @@ function App(props: Props) {
if (hasMyChannels) {
fetchModBlockedList();
fetchModAmIList();
if (activeChannelClaim && !defaultChannelClaim) doSetDefaultChannel(activeChannelClaim.claim_id);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [hasMyChannels, hasNoChannels, hasActiveChannelClaim, setIncognito]);

View file

@ -3,7 +3,7 @@ import { selectMyChannelClaims, selectClaimsByUri, selectOdyseeMembershipForUri
import { selectActiveChannelClaim, selectIncognito } from 'redux/selectors/app';
import { doSetActiveChannel, doSetIncognito } from 'redux/actions/app';
import { doFetchUserMemberships } from 'redux/actions/user';
import { doSetClientSetting } from 'redux/actions/settings';
import { doSetDefaultChannel } from 'redux/actions/settings';
import { selectDefaultChannelClaim } from 'redux/selectors/settings';
import ChannelSelector from './view';
@ -25,7 +25,7 @@ const perform = {
doSetActiveChannel,
doSetIncognito,
doFetchUserMemberships,
doSetClientSetting,
doSetDefaultChannel,
};
export default connect(select, perform)(ChannelSelector);

View file

@ -1,7 +1,6 @@
// @flow
import * as ICONS from 'constants/icons';
import * as PAGES from 'constants/pages';
import * as SETTINGS from 'constants/settings';
import classnames from 'classnames';
import React from 'react';
import ChannelThumbnail from 'component/channelThumbnail';
@ -25,7 +24,7 @@ type Props = {
doFetchUserMemberships: (claimIdCsv: string) => void,
odyseeMembershipByUri: (uri: string) => string,
storeSelection?: boolean,
doSetClientSetting: (key: string, value: string, pushPrefs: boolean) => void,
doSetDefaultChannel: (claimId: string) => void,
isHeaderMenu?: boolean,
autoSet?: boolean,
channelToSet?: string,
@ -42,7 +41,7 @@ export default function ChannelSelector(props: Props) {
claimsByUri,
doFetchUserMemberships,
storeSelection,
doSetClientSetting,
doSetDefaultChannel,
isHeaderMenu,
autoSet,
channelToSet,
@ -62,7 +61,7 @@ export default function ChannelSelector(props: Props) {
doSetActiveChannel(channelClaim.claim_id);
if (storeSelection) {
doSetClientSetting(SETTINGS.ACTIVE_CHANNEL_CLAIM, channelClaim.claim_id, true);
doSetDefaultChannel(channelClaim.claim_id);
}
}

View file

@ -515,3 +515,6 @@ export function toggleAutoplayNext() {
export const doSetDefaultVideoQuality = (value) => (dispatch) =>
dispatch(doSetClientSetting(SETTINGS.DEFAULT_VIDEO_QUALITY, value, true));
export const doSetDefaultChannel = (claimId) => (dispatch) =>
dispatch(doSetClientSetting(SETTINGS.ACTIVE_CHANNEL_CLAIM, claimId, true));