fix sync becoming untoggled

This commit is contained in:
Sean Yesmunt 2019-10-15 21:14:21 -04:00
parent a3b3a204b0
commit d7c0f5c6b7
6 changed files with 11 additions and 14 deletions

View file

@ -6,7 +6,6 @@ import { doFetchTransactions, doFetchChannelListMine, selectBalance } from 'lbry
import { makeSelectClientSetting, selectThemePath } from 'redux/selectors/settings'; import { makeSelectClientSetting, selectThemePath } from 'redux/selectors/settings';
import { selectIsUpgradeAvailable, selectAutoUpdateDownloaded } from 'redux/selectors/app'; import { selectIsUpgradeAvailable, selectAutoUpdateDownloaded } from 'redux/selectors/app';
import { doDownloadUpgradeRequested, doSignIn, doSyncWithPreferences } from 'redux/actions/app'; import { doDownloadUpgradeRequested, doSignIn, doSyncWithPreferences } from 'redux/actions/app';
import { doSetClientSetting } from 'redux/actions/settings';
import App from './view'; import App from './view';
const select = state => ({ const select = state => ({
@ -28,7 +27,6 @@ const perform = dispatch => ({
signIn: () => dispatch(doSignIn()), signIn: () => dispatch(doSignIn()),
requestDownloadUpgrade: () => dispatch(doDownloadUpgradeRequested()), requestDownloadUpgrade: () => dispatch(doDownloadUpgradeRequested()),
checkSync: () => dispatch(doSyncWithPreferences()), checkSync: () => dispatch(doSyncWithPreferences()),
setSyncEnabled: value => dispatch(doSetClientSetting(SETTINGS.ENABLE_SYNC, value)),
}); });
export default hot( export default hot(

View file

@ -40,7 +40,6 @@ type Props = {
isUpgradeAvailable: boolean, isUpgradeAvailable: boolean,
autoUpdateDownloaded: boolean, autoUpdateDownloaded: boolean,
checkSync: () => void, checkSync: () => void,
setSyncEnabled: boolean => void,
syncEnabled: boolean, syncEnabled: boolean,
}; };
@ -59,7 +58,6 @@ function App(props: Props) {
requestDownloadUpgrade, requestDownloadUpgrade,
syncEnabled, syncEnabled,
checkSync, checkSync,
setSyncEnabled,
} = props; } = props;
const appRef = useRef(); const appRef = useRef();
const isEnhancedLayout = useKonamiListener(); const isEnhancedLayout = useKonamiListener();
@ -126,9 +124,7 @@ function App(props: Props) {
}, [hasVerifiedEmail, signIn, hasSignedIn]); }, [hasVerifiedEmail, signIn, hasSignedIn]);
useEffect(() => { useEffect(() => {
if (!hasVerifiedEmail && syncEnabled) { if (userId && hasVerifiedEmail && syncEnabled) {
setSyncEnabled(false);
} else if (hasVerifiedEmail && syncEnabled) {
checkSync(); checkSync();
let syncInterval = setInterval(() => { let syncInterval = setInterval(() => {
@ -139,7 +135,7 @@ function App(props: Props) {
clearInterval(syncInterval); clearInterval(syncInterval);
}; };
} }
}, [hasVerifiedEmail, syncEnabled, checkSync, setSyncEnabled]); }, [hasVerifiedEmail, syncEnabled, checkSync, userId]);
if (!user) { if (!user) {
return null; return null;

View file

@ -22,7 +22,7 @@ export default function Card(props: Props) {
{icon && <Icon sectionIcon icon={icon} />} {icon && <Icon sectionIcon icon={icon} />}
<div> <div>
<h2 className="section__title">{title}</h2> <h2 className="section__title">{title}</h2>
<p className="section__subtitle">{subtitle}</p> <div className="section__subtitle">{subtitle}</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -11,7 +11,7 @@ type Props = {
function SyncToggle(props: Props) { function SyncToggle(props: Props) {
const { setSyncEnabled, syncEnabled, verifiedEmail } = props; const { setSyncEnabled, syncEnabled, verifiedEmail } = props;
console.log('??', syncEnabled);
function handleChange() { function handleChange() {
setSyncEnabled(!syncEnabled); setSyncEnabled(!syncEnabled);
} }

View file

@ -40,7 +40,7 @@ const WalletBalance = (props: Props) => {
<strong> <strong>
<CreditAmount badge={false} amount={tipsBalance} precision={8} /> <CreditAmount badge={false} amount={tipsBalance} precision={8} />
</strong>{' '} </strong>{' '}
{__('Earned and bound in tips')} {__('earned and bound in tips')}
</h2> </h2>
</div> </div>
</div> </div>
@ -50,7 +50,10 @@ const WalletBalance = (props: Props) => {
<Icon sectionIcon icon={ICONS.LOCK} /> <Icon sectionIcon icon={ICONS.LOCK} />
<div> <div>
<h2 className="section__title--small"> <h2 className="section__title--small">
<strong>{(claimsBalance + supportsBalance).toFixed(2)}</strong> {__('LBC Currently Staked')} <strong>
<CreditAmount badge={false} amount={claimsBalance + supportsBalance} precision={8} />
</strong>{' '}
{__('currently staked')}
</h2> </h2>
<div className="section__subtitle"> <div className="section__subtitle">
<dl> <dl>

View file

@ -641,11 +641,11 @@ class SettingsPage extends React.PureComponent<Props, State> {
<Card <Card
title={__('Application Cache')} title={__('Application Cache')}
subtitle={ subtitle={
<span className="card__subtitle--status"> <p className="card__subtitle--status">
{__( {__(
'This will clear the application cache. Your wallet will not be affected. Currently, followed tags and blocked channels will be cleared.' 'This will clear the application cache. Your wallet will not be affected. Currently, followed tags and blocked channels will be cleared.'
)} )}
</span> </p>
} }
actions={ actions={
<Button <Button