diff --git a/ui/component/settingAccount/index.js b/ui/component/settingAccount/index.js new file mode 100644 index 000000000..9abbe808b --- /dev/null +++ b/ui/component/settingAccount/index.js @@ -0,0 +1,15 @@ +import { connect } from 'react-redux'; +import { doWalletStatus, selectWalletIsEncrypted } from 'lbry-redux'; +import { selectUserVerifiedEmail } from 'redux/selectors/user'; +import SettingAccount from './view'; + +const select = (state) => ({ + isAuthenticated: selectUserVerifiedEmail(state), + walletEncrypted: selectWalletIsEncrypted(state), +}); + +const perform = (dispatch) => ({ + doWalletStatus: () => dispatch(doWalletStatus()), +}); + +export default connect(select, perform)(SettingAccount); diff --git a/ui/component/settingAccount/view.jsx b/ui/component/settingAccount/view.jsx new file mode 100644 index 000000000..4097b532d --- /dev/null +++ b/ui/component/settingAccount/view.jsx @@ -0,0 +1,55 @@ +// @flow +import React from 'react'; +import Card from 'component/common/card'; +import SettingAccountPassword from 'component/settingAccountPassword'; +import SyncToggle from 'component/syncToggle'; +import { getPasswordFromCookie } from 'util/saved-passwords'; + +type Props = { + // --- select --- + isAuthenticated: boolean, + walletEncrypted: boolean, + // --- perform --- + doWalletStatus: () => void, +}; + +export default function SettingAccount(props: Props) { + const { isAuthenticated, walletEncrypted, doWalletStatus } = props; + const [storedPassword, setStoredPassword] = React.useState(false); + + // Determine if password is stored. + React.useEffect(() => { + if (isAuthenticated || !IS_WEB) { + doWalletStatus(); + getPasswordFromCookie().then((p) => { + if (typeof p === 'string') { + setStoredPassword(true); + } + }); + } + // enterSettings(); @KP need to do this at each component, or just at Settings Page? + }, []); // eslint-disable-line react-hooks/exhaustive-deps + + return ( + + {isAuthenticated && ( +
+ +
+ )} + + {/* @if TARGET='app' */} +
+ +
+ {/* @endif */} + + } + /> + ); +} diff --git a/ui/component/settingAccountPassword/view.jsx b/ui/component/settingAccountPassword/view.jsx index a63dff59a..494d078e6 100644 --- a/ui/component/settingAccountPassword/view.jsx +++ b/ui/component/settingAccountPassword/view.jsx @@ -3,7 +3,6 @@ import React, { useState } from 'react'; import { FormField, Form } from 'component/common/form'; import Button from 'component/button'; import ErrorText from 'component/common/error-text'; -import Card from 'component/common/card'; import * as PAGES from 'constants/pages'; type Props = { @@ -38,54 +37,52 @@ export default function SettingAccountPassword(props: Props) { } }, [passwordSetSuccess, setOldPassword, setNewPassword, doClearPasswordEntry, doToast]); - return ( - -
- {hasPassword && ( - setOldPassword(e.target.value)} - /> - )} - setNewPassword(e.target.value)} - /> - -
-
- - {passwordSetError && ( -
- {passwordSetError} -
- )} - - ) : ( -