lbry-desktop/ui/component/settingAccount/view.jsx

80 lines
2.3 KiB
React
Raw Normal View History

// @flow
2021-08-06 09:43:21 +02:00
import * as ICONS from 'constants/icons';
import * as PAGES from 'constants/pages';
import { SETTINGS_GRP } from 'constants/settings';
import React from 'react';
2021-08-06 09:43:21 +02:00
import Button from 'component/button';
import Card from 'component/common/card';
2021-08-06 09:43:21 +02:00
import SettingsRow from 'component/settingsRow';
import SyncToggle from 'component/syncToggle';
import { getPasswordFromCookie } from 'util/saved-passwords';
type Props = {
// --- select ---
isAuthenticated: boolean,
walletEncrypted: boolean,
2021-08-06 09:43:21 +02:00
user: User,
myChannels: ?Array<ChannelClaim>,
// --- perform ---
doWalletStatus: () => void,
};
export default function SettingAccount(props: Props) {
2021-10-19 19:57:24 +02:00
const { isAuthenticated, walletEncrypted, myChannels, 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);
}
});
}
}, []); // eslint-disable-line react-hooks/exhaustive-deps
return (
<>
<div className="card__title-section">
<h2 className="card__title">{__('Account')}</h2>
</div>
<Card
id={SETTINGS_GRP.ACCOUNT}
isBodyList
body={
<>
{isAuthenticated && (
2021-08-23 08:18:27 +02:00
<SettingsRow title={__('Password')}>
<Button
button="inverse"
label={__('Manage')}
icon={ICONS.ARROW_RIGHT}
navigate={`/$/${PAGES.SETTINGS_UPDATE_PWD}`}
/>
</SettingsRow>
)}
{/* @if TARGET='app' */}
<SyncToggle disabled={walletEncrypted && !storedPassword && storedPassword !== ''} />
{/* @endif */}
{myChannels && (
<SettingsRow title={__('Comments')} subtitle={__('View your past comments.')}>
<Button
button="inverse"
label={__('Manage')}
icon={ICONS.ARROW_RIGHT}
navigate={`/$/${PAGES.SETTINGS_OWN_COMMENTS}`}
/>
</SettingsRow>
)}
</>
}
/>
</>
);
}