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

View file

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

View file

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

View file

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