more odysee feature cleanup

This commit is contained in:
zeppi 2022-07-03 13:18:32 -04:00
parent df6be2ac8f
commit 16fe53c47d
17 changed files with 6 additions and 330 deletions

View file

@ -6,12 +6,11 @@ import { selectClientSetting } from 'redux/selectors/settings';
import { selectGetSyncErrorMessage } from 'redux/selectors/sync'; import { selectGetSyncErrorMessage } from 'redux/selectors/sync';
import { selectHasNavigated } from 'redux/selectors/app'; import { selectHasNavigated } from 'redux/selectors/app';
import { selectTotalBalance, selectBalance } from 'redux/selectors/wallet'; import { selectTotalBalance, selectBalance } from 'redux/selectors/wallet';
import { selectUserVerifiedEmail, selectEmailToVerify, selectUser } from 'redux/selectors/user'; import { selectEmailToVerify, selectUser } from 'redux/selectors/user';
import * as SETTINGS from 'constants/settings'; import * as SETTINGS from 'constants/settings';
import Header from './view'; import Header from './view';
const select = (state) => ({ const select = (state) => ({
authenticated: selectUserVerifiedEmail(state),
balance: selectBalance(state), balance: selectBalance(state),
emailToVerify: selectEmailToVerify(state), emailToVerify: selectEmailToVerify(state),
hasNavigated: selectHasNavigated(state), hasNavigated: selectHasNavigated(state),

View file

@ -4,11 +4,10 @@ import { selectActiveChannelStakedLevel } from 'redux/selectors/app';
import { selectClientSetting } from 'redux/selectors/settings'; import { selectClientSetting } from 'redux/selectors/settings';
import * as SETTINGS from 'constants/settings'; import * as SETTINGS from 'constants/settings';
import HeaderMenuButtons from './view'; import HeaderMenuButtons from './view';
import { selectUserVerifiedEmail, selectUser } from 'redux/selectors/user'; import { selectUser } from 'redux/selectors/user';
const select = (state) => ({ const select = (state) => ({
activeChannelStakedLevel: selectActiveChannelStakedLevel(state), activeChannelStakedLevel: selectActiveChannelStakedLevel(state),
authenticated: selectUserVerifiedEmail(state),
automaticDarkModeEnabled: selectClientSetting(state, SETTINGS.AUTOMATIC_DARK_MODE_ENABLED), automaticDarkModeEnabled: selectClientSetting(state, SETTINGS.AUTOMATIC_DARK_MODE_ENABLED),
currentTheme: selectClientSetting(state, SETTINGS.THEME), currentTheme: selectClientSetting(state, SETTINGS.THEME),
user: selectUser(state), user: selectUser(state),

View file

@ -12,7 +12,6 @@ import React from 'react';
import Tooltip from 'component/common/tooltip'; import Tooltip from 'component/common/tooltip';
type HeaderMenuButtonProps = { type HeaderMenuButtonProps = {
authenticated: boolean,
automaticDarkModeEnabled: boolean, automaticDarkModeEnabled: boolean,
currentTheme: string, currentTheme: string,
user: ?User, user: ?User,

View file

@ -226,18 +226,20 @@ function AppRouter(props: Props) {
/> />
))} ))}
{/* Odysee signin */}
<Route path={`/$/${PAGES.AUTH_SIGNIN}`} exact component={SignInPage} /> <Route path={`/$/${PAGES.AUTH_SIGNIN}`} exact component={SignInPage} />
<Route path={`/$/${PAGES.AUTH_PASSWORD_RESET}`} exact component={PasswordResetPage} /> <Route path={`/$/${PAGES.AUTH_PASSWORD_RESET}`} exact component={PasswordResetPage} />
<Route path={`/$/${PAGES.AUTH_PASSWORD_SET}`} exact component={PasswordSetPage} /> <Route path={`/$/${PAGES.AUTH_PASSWORD_SET}`} exact component={PasswordSetPage} />
<Route path={`/$/${PAGES.AUTH}`} exact component={SignUpPage} /> <Route path={`/$/${PAGES.AUTH}`} exact component={SignUpPage} />
<Route path={`/$/${PAGES.AUTH}/*`} exact component={SignUpPage} /> <Route path={`/$/${PAGES.AUTH}/*`} exact component={SignUpPage} />
<Route path={`/$/${PAGES.AUTH_VERIFY}`} exact component={SignInVerifyPage} />
<Route path={`/$/${PAGES.WELCOME}`} exact component={Welcome} /> <Route path={`/$/${PAGES.WELCOME}`} exact component={Welcome} />
<Route path={`/$/${PAGES.HELP}`} exact component={HelpPage} /> <Route path={`/$/${PAGES.HELP}`} exact component={HelpPage} />
{/* @if TARGET='app' */} {/* @if TARGET='app' */}
<Route path={`/$/${PAGES.BACKUP}`} exact component={BackupPage} /> <Route path={`/$/${PAGES.BACKUP}`} exact component={BackupPage} />
{/* @endif */} {/* @endif */}
<Route path={`/$/${PAGES.AUTH_VERIFY}`} exact component={SignInVerifyPage} />
<Route path={`/$/${PAGES.SEARCH}`} exact component={SearchPage} /> <Route path={`/$/${PAGES.SEARCH}`} exact component={SearchPage} />
<Route path={`/$/${PAGES.TOP}`} exact component={TopPage} /> <Route path={`/$/${PAGES.TOP}`} exact component={TopPage} />
<Route path={`/$/${PAGES.SETTINGS}`} exact component={SettingsPage} /> <Route path={`/$/${PAGES.SETTINGS}`} exact component={SettingsPage} />

View file

@ -43,7 +43,6 @@ type Props = {
toggleVideoTheaterMode: () => void, toggleVideoTheaterMode: () => void,
toggleAutoplayNext: () => void, toggleAutoplayNext: () => void,
setVideoPlaybackRate: (number) => void, setVideoPlaybackRate: (number) => void,
authenticated: boolean,
userId: number, userId: number,
homepageData?: { [string]: HomepageCat }, homepageData?: { [string]: HomepageCat },
shareTelemetry: boolean, shareTelemetry: boolean,

View file

@ -3,14 +3,12 @@ import { doSetDaemonSetting } from 'redux/actions/settings';
import { doSetWelcomeVersion } from 'redux/actions/app'; import { doSetWelcomeVersion } from 'redux/actions/app';
import * as DAEMON_SETTINGS from 'constants/daemon_settings'; import * as DAEMON_SETTINGS from 'constants/daemon_settings';
import { WELCOME_VERSION } from 'config.js'; import { WELCOME_VERSION } from 'config.js';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
import { selectDaemonSettings, selectDaemonStatus } from 'redux/selectors/settings'; import { selectDaemonSettings, selectDaemonStatus } from 'redux/selectors/settings';
import WelcomeSplash from './view'; import WelcomeSplash from './view';
import { selectDiskSpace } from 'redux/selectors/app'; import { selectDiskSpace } from 'redux/selectors/app';
const select = (state) => ({ const select = (state) => ({
authenticated: selectUserVerifiedEmail(state),
diskSpace: selectDiskSpace(state), diskSpace: selectDiskSpace(state),
daemonSettings: selectDaemonSettings(state), daemonSettings: selectDaemonSettings(state),
daemonStatus: selectDaemonStatus(state), daemonStatus: selectDaemonStatus(state),

View file

@ -9,7 +9,6 @@ import YrblHappy from 'static/img/yrblhappy.svg';
type Props = { type Props = {
setWelcomeVersion: (number) => void, setWelcomeVersion: (number) => void,
setShareDataInternal: (boolean) => void, setShareDataInternal: (boolean) => void,
authenticated: boolean,
handleNextPage: () => void, handleNextPage: () => void,
diskSpace?: DiskSpace, diskSpace?: DiskSpace,
}; };

View file

@ -33,7 +33,6 @@ export const WALLET_UNLOCK = 'wallet_unlock';
export const WALLET_SYNC = 'wallet_sync'; export const WALLET_SYNC = 'wallet_sync';
export const WALLET_PASSWORD_UNSAVE = 'wallet_password_unsave'; export const WALLET_PASSWORD_UNSAVE = 'wallet_password_unsave';
export const CREATE_CHANNEL = 'create_channel'; export const CREATE_CHANNEL = 'create_channel';
export const SET_REFERRER = 'set_referrer';
export const SIGN_OUT = 'sign_out'; export const SIGN_OUT = 'sign_out';
export const LIQUIDATE_SUPPORTS = 'liquidate_supports'; export const LIQUIDATE_SUPPORTS = 'liquidate_supports';
export const MASS_TIP_UNLOCK = 'mass_tip_unlock'; export const MASS_TIP_UNLOCK = 'mass_tip_unlock';

View file

@ -51,7 +51,6 @@ import ModalRevokeClaim from 'modal/modalRevokeClaim';
import ModalRewardCode from 'modal/modalRewardCode'; import ModalRewardCode from 'modal/modalRewardCode';
import ModalSendTip from 'modal/modalSendTip'; import ModalSendTip from 'modal/modalSendTip';
import ModalRepost from 'modal/modalRepost'; import ModalRepost from 'modal/modalRepost';
import ModalSetReferrer from 'modal/modalSetReferrer';
import ModalSignOut from 'modal/modalSignOut'; import ModalSignOut from 'modal/modalSignOut';
import ModalSocialShare from 'modal/modalSocialShare'; import ModalSocialShare from 'modal/modalSocialShare';
import ModalSupportsLiquidate from 'modal/modalSupportsLiquidate'; import ModalSupportsLiquidate from 'modal/modalSupportsLiquidate';
@ -122,8 +121,6 @@ function getModal(id) {
return ModalRewardCode; return ModalRewardCode;
case MODALS.COMMENT_ACKNOWEDGEMENT: case MODALS.COMMENT_ACKNOWEDGEMENT:
return ModalCommentAcknowledgement; return ModalCommentAcknowledgement;
case MODALS.SET_REFERRER:
return ModalSetReferrer;
case MODALS.SIGN_OUT: case MODALS.SIGN_OUT:
return ModalSignOut; return ModalSignOut;
case MODALS.FILE_SELECTION: case MODALS.FILE_SELECTION:

View file

@ -1,18 +0,0 @@
import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app';
import { selectSetReferrerError, selectSetReferrerPending } from 'redux/selectors/user';
import { doUserSetReferrer, doUserSetReferrerReset } from 'redux/actions/user';
import ModalSetReferrer from './view';
const select = state => ({
referrerSetPending: selectSetReferrerPending(state),
referrerSetError: selectSetReferrerError(state),
});
const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()),
setReferrer: (referrer, doClaim) => dispatch(doUserSetReferrer(referrer, doClaim)),
resetReferrerError: () => dispatch(doUserSetReferrerReset()),
});
export default connect(select, perform)(ModalSetReferrer);

View file

@ -1,101 +0,0 @@
// @flow
import * as React from 'react';
import { FormField, Form } from 'component/common/form';
import { Modal } from 'modal/modal';
import Button from 'component/button';
import HelpLink from 'component/common/help-link';
import Card from 'component/common/card';
type Props = {
closeModal: () => void,
error: ?string,
rewardIsPending: boolean,
setReferrer: (string, boolean) => void,
referrerSetPending: boolean,
referrerSetError?: string,
resetReferrerError: () => void,
};
type State = {
referrer: string,
};
class ModalSetReferrer extends React.PureComponent<Props, State> {
constructor() {
super();
this.state = {
referrer: '',
};
(this: any).handleSubmit = this.handleSubmit.bind(this);
(this: any).handleClose = this.handleClose.bind(this);
(this: any).handleTextChange = this.handleTextChange.bind(this);
}
handleSubmit() {
const { referrer } = this.state;
const { setReferrer } = this.props;
setReferrer(referrer, true);
}
handleClose() {
const { referrerSetError, resetReferrerError, closeModal } = this.props;
if (referrerSetError) {
resetReferrerError();
}
closeModal();
}
handleTextChange(e: SyntheticInputEvent<*>) {
const { referrerSetError, resetReferrerError } = this.props;
this.setState({ referrer: e.target.value });
if (referrerSetError) {
resetReferrerError();
}
}
render() {
const { closeModal, rewardIsPending, referrerSetError, referrerSetPending } = this.props;
const { referrer } = this.state;
return (
<Modal isOpen contentLabel={__('Enter inviter')} type="card" onAborted={closeModal}>
<Card
title={__('Enter inviter')}
subtitle={
<React.Fragment>
{__('Did someone invite you to use LBRY? Tell us who and you both get a reward!')}
<HelpLink href="https://lbry.com/faq/referrals" />
</React.Fragment>
}
actions={
<React.Fragment>
<Form onSubmit={this.handleSubmit}>
<FormField
autoFocus
type="text"
name="referrer-code"
inputButton={
<Button button="primary" type="submit" disabled={!referrer || rewardIsPending} label={__('Set')} />
}
label={__('Code or channel')}
placeholder="0123abc"
value={referrer}
onChange={this.handleTextChange}
error={!referrerSetPending && referrerSetError}
/>
</Form>
<div className="card__actions">
<Button button="primary" label={__('Done')} onClick={this.handleClose} />
</div>
</React.Fragment>
}
/>
</Modal>
);
}
}
export default ModalSetReferrer;

View file

@ -13,7 +13,6 @@ import { useIsLargeScreen } from 'effects/use-screensize';
import { GetLinksData } from 'util/buildHomepage'; import { GetLinksData } from 'util/buildHomepage';
type Props = { type Props = {
authenticated: boolean,
followedTags: Array<Tag>, followedTags: Array<Tag>,
subscribedChannels: Array<Subscription>, subscribedChannels: Array<Subscription>,
showNsfw: boolean, showNsfw: boolean,

View file

@ -1,13 +1,11 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doEnterSettingsPage, doExitSettingsPage } from 'redux/actions/settings'; import { doEnterSettingsPage, doExitSettingsPage } from 'redux/actions/settings';
import { selectDaemonSettings } from 'redux/selectors/settings'; import { selectDaemonSettings } from 'redux/selectors/settings';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
import SettingsPage from './view'; import SettingsPage from './view';
const select = (state) => ({ const select = (state) => ({
daemonSettings: selectDaemonSettings(state), daemonSettings: selectDaemonSettings(state),
isAuthenticated: selectUserVerifiedEmail(state),
}); });
const perform = (dispatch) => ({ const perform = (dispatch) => ({

View file

@ -14,7 +14,6 @@ type DaemonSettings = {
type Props = { type Props = {
daemonSettings: DaemonSettings, daemonSettings: DaemonSettings,
isAuthenticated: boolean,
enterSettings: () => void, enterSettings: () => void,
exitSettings: () => void, exitSettings: () => void,
}; };

View file

@ -4,7 +4,6 @@ import { doToast } from 'redux/actions/notifications';
import * as ACTIONS from 'constants/action_types'; import * as ACTIONS from 'constants/action_types';
import { selectUnclaimedRewards } from 'redux/selectors/rewards'; import { selectUnclaimedRewards } from 'redux/selectors/rewards';
import { selectUserIsRewardApproved } from 'redux/selectors/user'; import { selectUserIsRewardApproved } from 'redux/selectors/user';
// import { doFetchInviteStatus } from 'redux/actions/user';
import rewards from 'rewards'; import rewards from 'rewards';
export function doRewardList() { export function doRewardList() {

View file

@ -6,7 +6,7 @@ import { batchActions } from 'util/batch-actions';
import * as ACTIONS from 'constants/action_types'; import * as ACTIONS from 'constants/action_types';
import { doClaimRewardType, doRewardList } from 'redux/actions/rewards'; import { doClaimRewardType, doRewardList } from 'redux/actions/rewards';
import { selectEmailToVerify, selectPhoneToVerify, selectUserCountryCode, selectUser } from 'redux/selectors/user'; import { selectUser } from 'redux/selectors/user';
import rewards from 'rewards'; import rewards from 'rewards';
import { Lbryio } from 'lbryinc'; import { Lbryio } from 'lbryinc';
import { DOMAIN } from 'config'; import { DOMAIN } from 'config';
@ -14,37 +14,6 @@ import { getDefaultLanguage } from 'util/default-languages';
const AUTH_IN_PROGRESS = 'authInProgress'; const AUTH_IN_PROGRESS = 'authInProgress';
export let sessionStorageAvailable = false; export let sessionStorageAvailable = false;
export function doFetchInviteStatus(shouldCallRewardList = true) {
return (dispatch) => {
dispatch({
type: ACTIONS.USER_INVITE_STATUS_FETCH_STARTED,
});
Promise.all([Lbryio.call('user', 'invite_status'), Lbryio.call('user_referral_code', 'list')])
.then(([status, code]) => {
if (shouldCallRewardList) {
dispatch(doRewardList());
}
dispatch({
type: ACTIONS.USER_INVITE_STATUS_FETCH_SUCCESS,
data: {
invitesRemaining: status.invites_remaining ? status.invites_remaining : 0,
invitees: status.invitees,
referralLink: `${Lbryio.CONNECTION_STRING}user/refer?r=${code}`,
referralCode: code,
},
});
})
.catch((error) => {
dispatch({
type: ACTIONS.USER_INVITE_STATUS_FETCH_FAILURE,
data: { error },
});
});
};
}
export function doInstallNew(appVersion, os = null, firebaseToken = null, callbackForUsersWhoAreSharingData, domain) { export function doInstallNew(appVersion, os = null, firebaseToken = null, callbackForUsersWhoAreSharingData, domain) {
const payload = { app_version: appVersion, domain }; const payload = { app_version: appVersion, domain };
if (firebaseToken) { if (firebaseToken) {
@ -211,95 +180,6 @@ export function doUserPhoneNew(phone, countryCode) {
}; };
} }
export function doUserPhoneVerifyFailure(error) {
return {
type: ACTIONS.USER_PHONE_VERIFY_FAILURE,
data: { error },
};
}
export function doUserPhoneVerify(verificationCode) {
return (dispatch, getState) => {
const phoneNumber = selectPhoneToVerify(getState());
const countryCode = selectUserCountryCode(getState());
dispatch({
type: ACTIONS.USER_PHONE_VERIFY_STARTED,
code: verificationCode,
});
Lbryio.call(
'user',
'phone_number_confirm',
{
verification_code: verificationCode,
phone_number: phoneNumber,
country_code: countryCode,
},
'post'
)
.then((user) => {
if (user.is_identity_verified) {
dispatch({
type: ACTIONS.USER_PHONE_VERIFY_SUCCESS,
data: { user },
});
dispatch(doClaimRewardType(rewards.TYPE_NEW_USER));
}
})
.catch((error) => dispatch(doUserPhoneVerifyFailure(error)));
};
}
export function doUserEmailToVerify(email) {
return (dispatch) => {
dispatch({
type: ACTIONS.USER_EMAIL_VERIFY_SET,
data: { email },
});
};
}
export function doUserEmailNew(email) {
return (dispatch) => {
dispatch({
type: ACTIONS.USER_EMAIL_NEW_STARTED,
email,
});
const success = () => {
dispatch({
type: ACTIONS.USER_EMAIL_NEW_SUCCESS,
data: { email },
});
dispatch(doUserFetch());
};
const failure = (error) => {
dispatch({
type: ACTIONS.USER_EMAIL_NEW_FAILURE,
data: { error },
});
};
Lbryio.call('user_email', 'new', { email, send_verification_email: true }, 'post')
.catch((error) => {
if (error.response && error.response.status === 409) {
dispatch({
type: ACTIONS.USER_EMAIL_NEW_EXISTS,
});
return Lbryio.call('user_email', 'resend_token', { email, only_if_expired: true }, 'post').then(
success,
failure
);
}
throw error;
})
.then(success, failure);
};
}
export function doUserCheckIfEmailExists(email) { export function doUserCheckIfEmailExists(email) {
return (dispatch) => { return (dispatch) => {
dispatch({ dispatch({
@ -530,41 +410,6 @@ export function doUserEmailVerifyFailure(error) {
}; };
} }
export function doUserEmailVerify(verificationToken, recaptcha) {
return (dispatch, getState) => {
const email = selectEmailToVerify(getState());
dispatch({
type: ACTIONS.USER_EMAIL_VERIFY_STARTED,
code: verificationToken,
recaptcha,
});
Lbryio.call(
'user_email',
'confirm',
{
verification_token: verificationToken,
email,
recaptcha,
},
'post'
)
.then((userEmail) => {
if (userEmail.is_verified) {
dispatch({
type: ACTIONS.USER_EMAIL_VERIFY_SUCCESS,
data: { email },
});
dispatch(doUserFetch());
} else {
throw new Error('Your email is still not verified.'); // shouldn't happen
}
})
.catch((error) => dispatch(doUserEmailVerifyFailure(error)));
};
}
export function doFetchAccessToken() { export function doFetchAccessToken() {
return (dispatch) => { return (dispatch) => {
const success = (token) => const success = (token) =>
@ -576,34 +421,6 @@ export function doFetchAccessToken() {
}; };
} }
export function doUserIdentityVerify(stripeToken) {
return (dispatch) => {
dispatch({
type: ACTIONS.USER_IDENTITY_VERIFY_STARTED,
token: stripeToken,
});
Lbryio.call('user', 'verify_identity', { stripe_token: stripeToken }, 'post')
.then((user) => {
if (user.is_identity_verified) {
dispatch({
type: ACTIONS.USER_IDENTITY_VERIFY_SUCCESS,
data: { user },
});
dispatch(doClaimRewardType(rewards.TYPE_NEW_USER));
} else {
throw new Error('Your identity is still not verified. This should not happen.'); // shouldn't happen
}
})
.catch((error) => {
dispatch({
type: ACTIONS.USER_IDENTITY_VERIFY_FAILURE,
data: { error: error.toString() },
});
});
};
}
export function doUserSetReferrerReset() { export function doUserSetReferrerReset() {
return (dispatch) => { return (dispatch) => {
dispatch({ dispatch({

View file

@ -19,8 +19,6 @@ export const selectUserEmail = createSelector(selectUser, (user) =>
user ? user.primary_email || user.latest_claimed_email : null user ? user.primary_email || user.latest_claimed_email : null
); );
export const selectUserPhone = createSelector(selectUser, (user) => (user ? user.phone_number : null));
export const selectUserCountryCode = createSelector(selectUser, (user) => (user ? user.country_code : null)); export const selectUserCountryCode = createSelector(selectUser, (user) => (user ? user.country_code : null));
export const selectEmailToVerify = createSelector( export const selectEmailToVerify = createSelector(
@ -29,12 +27,6 @@ export const selectEmailToVerify = createSelector(
(state, userEmail) => state.emailToVerify || userEmail (state, userEmail) => state.emailToVerify || userEmail
); );
export const selectPhoneToVerify = createSelector(
selectState,
selectUserPhone,
(state, userPhone) => state.phoneToVerify || userPhone
);
export const selectYoutubeChannels = createSelector(selectUser, (user) => (user ? user.youtube_channels : null)); export const selectYoutubeChannels = createSelector(selectUser, (user) => (user ? user.youtube_channels : null));
export const selectUserIsRewardApproved = createSelector(selectUser, (user) => user && user.is_reward_approved); export const selectUserIsRewardApproved = createSelector(selectUser, (user) => user && user.is_reward_approved);