add sync checkbox to desktop

This commit is contained in:
Sean Yesmunt 2020-04-20 13:13:41 -04:00
parent a863cbaec5
commit c30d158704
3 changed files with 38 additions and 2 deletions

View file

@ -1161,5 +1161,10 @@
"You have %count% blocked %channels%.": "You have %count% blocked %channels%.",
"Account Password": "Account Password",
"You do not currently have a password set.": "You do not currently have a password set.",
"Add A Password": "Add A Password"
"Add A Password": "Add A Password",
"Register with lbry.tv": "Register with lbry.tv",
"Enter Your lbry.tv Password": "Enter Your lbry.tv Password",
"Signing in as %email%": "Signing in as %email%",
"Forgot Password?": "Forgot Password?",
"Use Magic Link": "Use Magic Link"
}

View file

@ -7,6 +7,7 @@ import {
selectEmailDoesNotExist,
selectEmailAlreadyExists,
} from 'lbryinc';
import { doSetClientSetting } from 'redux/actions/settings';
import UserEmailReturning from './view';
const select = state => ({
@ -19,4 +20,5 @@ const select = state => ({
export default connect(select, {
doUserCheckIfEmailExists,
doClearEmailEntry,
doSetClientSetting,
})(UserEmailReturning);

View file

@ -1,4 +1,5 @@
// @flow
import * as SETTINGS from 'constants/settings';
import * as PAGES from 'constants/pages';
import React, { useState } from 'react';
import { FormField, Form } from 'component/common/form';
@ -16,20 +17,33 @@ type Props = {
doClearEmailEntry: () => void,
doUserSignIn: (string, ?string) => void,
doUserCheckIfEmailExists: string => void,
doSetClientSetting: (string, boolean) => void,
};
function UserEmailReturning(props: Props) {
const { errorMessage, doUserCheckIfEmailExists, emailToVerify, doClearEmailEntry, emailDoesNotExist } = props;
const {
errorMessage,
doUserCheckIfEmailExists,
emailToVerify,
doClearEmailEntry,
emailDoesNotExist,
doSetClientSetting,
} = props;
const { push, location } = useHistory();
const urlParams = new URLSearchParams(location.search);
const emailFromUrl = urlParams.get('email');
const emailExistsFromUrl = urlParams.get('email_exists');
const defaultEmail = emailFromUrl ? decodeURIComponent(emailFromUrl) : '';
const [email, setEmail] = useState(defaultEmail);
const [syncEnabled, setSyncEnabled] = useState(true);
const valid = email.match(EMAIL_REGEX);
const showEmailVerification = emailToVerify;
function handleSubmit() {
// @if TARGET='app'
doSetClientSetting(SETTINGS.ENABLE_SYNC, syncEnabled);
// @endif
doUserCheckIfEmailExists(email);
}
@ -69,6 +83,21 @@ function UserEmailReturning(props: Props) {
onChange={e => setEmail(e.target.value)}
/>
{/* @if TARGET='app' */}
<FormField
type="checkbox"
name="sync_checkbox"
label={
<React.Fragment>
{__('Backup your account and wallet data.')}{' '}
<Button button="link" href="https://lbry.com/faq/account-sync" label={__('Learn More')} />
</React.Fragment>
}
checked={syncEnabled}
onChange={() => setSyncEnabled(!syncEnabled)}
/>
{/* @endif */}
<div className="section__actions">
<Button
autoFocus={emailExistsFromUrl}