sync improvements

This commit is contained in:
Sean Yesmunt 2019-10-04 12:56:09 -04:00
parent 812367f0cc
commit 589a19b6e2
10 changed files with 79 additions and 18 deletions

View file

@ -129,7 +129,7 @@
"json-loader": "^0.5.4",
"lbry-format": "https://github.com/lbryio/lbry-format.git",
"lbry-redux": "lbryio/lbry-redux#85fe532d69704a283fd2ec640ad6e3b8dacd6d0d",
"lbryinc": "lbryio/lbryinc#44b6373ada13299a0fba1e60ac508f485af75388",
"lbryinc": "lbryio/lbryinc#d1dba98bb6f1dc67bc0db4c0a20fc13b8a0de98b",
"lint-staged": "^7.0.2",
"localforage": "^1.7.1",
"lodash-es": "^4.17.14",

View file

@ -2,7 +2,7 @@ import * as SETTINGS from 'constants/settings';
import { hot } from 'react-hot-loader/root';
import { connect } from 'react-redux';
import { selectUser, doRewardList, doFetchRewardedContent, doFetchAccessToken } from 'lbryinc';
import { doFetchTransactions, doFetchChannelListMine } from 'lbry-redux';
import { doFetchTransactions, doFetchChannelListMine, selectBalance } from 'lbry-redux';
import { makeSelectClientSetting, selectThemePath } from 'redux/selectors/settings';
import { selectIsUpgradeAvailable, selectAutoUpdateDownloaded } from 'redux/selectors/app';
import { doDownloadUpgradeRequested, doSignIn } from 'redux/actions/app';
@ -14,6 +14,7 @@ const select = state => ({
language: makeSelectClientSetting(SETTINGS.LANGUAGE)(state),
autoUpdateDownloaded: selectAutoUpdateDownloaded(state),
isUpgradeAvailable: selectIsUpgradeAvailable(state),
balance: selectBalance(state),
});
const perform = dispatch => ({

View file

@ -34,6 +34,7 @@ type Props = {
onSignedIn: () => void,
isUpgradeAvailable: boolean,
autoUpdateDownloaded: boolean,
balance: ?number,
};
function App(props: Props) {
@ -49,6 +50,7 @@ function App(props: Props) {
autoUpdateDownloaded,
isUpgradeAvailable,
requestDownloadUpgrade,
balance,
} = props;
const appRef = useRef();
const isEnhancedLayout = useKonamiListener();
@ -106,10 +108,10 @@ function App(props: Props) {
// Keep this at the end to ensure initial setup effects are run first
useEffect(() => {
if (!previousHasVerifiedEmail && hasVerifiedEmail) {
if (hasVerifiedEmail && balance !== undefined) {
signIn();
}
}, [previousHasVerifiedEmail, hasVerifiedEmail, signIn]);
}, [hasVerifiedEmail, signIn, balance]);
if (!user) {
return null;

View file

@ -45,7 +45,7 @@ function SyncPassword(props: Props) {
onChange={() => setRememberPassword(!rememberPassword)}
/>
<div className="card__actions">
<Button type="submit" button="primary" label={__('Continue')} disabled={!password || getSyncIsPending} />
<Button type="submit" button="primary" label={__('Continue')} disabled={getSyncIsPending} />
</div>
</div>
}

View file

@ -112,7 +112,6 @@ function UserSignIn(props: Props) {
showEmail && <UserEmailNew />,
showEmailVerification && <UserEmailVerify />,
showUserVerification && <UserVerify />,
showSyncPassword && <SyncPassword />,
showChannelCreation && <UserFirstChannel />,
// @if TARGET='app'
showYoutubeTransfer && (
@ -120,6 +119,7 @@ function UserSignIn(props: Props) {
<YoutubeTransferStatus /> <Confetti recycle={false} style={{ position: 'fixed' }} />
</div>
),
showSyncPassword && <SyncPassword />,
// @endif
showLoadingSpinner && (
<div className="main--empty">

View file

@ -49,7 +49,7 @@ const perform = dispatch => ({
decryptWallet: () => dispatch(doWalletDecrypt()),
updateWalletStatus: () => dispatch(doWalletStatus()),
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
getSync: password => dispatch(doGetSync(password)),
getSync: password => dispatch(doGetSync(password, true)),
checkSync: () => dispatch(doCheckSync()),
setDefaultAccount: () => dispatch(doSetDefaultAccount()),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),

View file

@ -24,10 +24,13 @@ class ModalWalletUnlock extends React.PureComponent<Props, State> {
};
componentDidMount() {
const { unlockWallet } = this.props;
getSavedPassword()
.then(p => {
if (p) {
if (p !== null) {
this.setState({ password: p, rememberPassword: true });
unlockWallet(p);
}
})
.catch();

View file

@ -37,7 +37,7 @@ import { Lbryio, doAuthenticate, doGetSync, selectSyncHash, doResetSync } from '
import { lbrySettings as config, version as appVersion } from 'package.json';
import { push } from 'connected-react-router';
import analytics from 'analytics';
import { deleteAuthToken } from 'util/saved-passwords';
import { deleteAuthToken, getSavedPassword } from 'util/saved-passwords';
import cookie from 'cookie';
import { makeSelectClientSetting } from 'redux/selectors/settings';
@ -461,16 +461,19 @@ export function doSignIn() {
// @if TARGET='app'
const state = getState();
const syncEnabled = makeSelectClientSetting(SETTINGS.ENABLE_SYNC)(state);
const syncHash = selectSyncHash(state);
const hasSyncedBefore = selectSyncHash(state);
const balance = selectBalance(state);
// For existing users, check if they've synced before, or have 0 balance
if (syncEnabled && (syncHash || balance === 0)) {
dispatch(doGetSync());
if (syncEnabled && (hasSyncedBefore || balance === 0)) {
getSavedPassword().then(password => {
const passwordArgument = password === null ? '' : password;
dispatch(doGetSync(passwordArgument, !hasSyncedBefore));
setInterval(() => {
dispatch(doGetSync());
}, 1000 * 60 * 5);
setInterval(() => {
dispatch(doGetSync(passwordArgument));
}, 1000 * 60 * 5);
});
}
// @endif

View file

@ -738,5 +738,57 @@
"Earned and bound in tips": "Earned and bound in tips",
"LBC Currently Staked": "LBC Currently Staked",
"... in your publishes": "... in your publishes",
"... in your supports": "... in your supports"
"... in your supports": "... in your supports",
"Add a tag": "Add a tag",
"Publish something totally wacky and wild.": "Publish something totally wacky and wild.",
"Available Rewards": "Available Rewards",
"Nothing published to LBRY yet.": "Nothing published to LBRY yet.",
"Follow New Tags": "Follow New Tags",
"Sign In": "Sign In",
"Go Back": "Go Back",
"Welcome To LBRY": "Welcome To LBRY",
"Create a new account or sign in.": "Create a new account or sign in.",
"hotstuff_96@hotmail.com": "hotstuff_96@hotmail.com",
"Terms of Service": "Terms of Service",
"Sync balance and preferences across devices": "Sync balance and preferences across devices",
"Learn More": "Learn More",
"I am over the age of 13 and agree to the %terms%.": "I am over the age of 13 and agree to the %terms%.",
"Blockchain expert? %learn_more%": "Blockchain expert? %learn_more%",
"Confirm Your Email": "Confirm Your Email",
"Follow the link to sign in. This will update automatically.": "Follow the link to sign in. This will update automatically.",
"Resend Verification Email": "Resend Verification Email",
"Start Over": "Start Over",
"Your YouTube Channel": "Your YouTube Channel",
"Please check back later.": "Please check back later.",
"here": "here",
"%channelName% is not ready to be transferred. You can check the status %statusLink% or check back later.": "%channelName% is not ready to be transferred. You can check the status %statusLink% or check back later.",
"Enter Your LBRY Password": "Enter Your LBRY Password",
"You set your wallet password when you previously installed LBRY.": "You set your wallet password when you previously installed LBRY.",
"Remember My Password": "Remember My Password",
"Extra Verification Needed": "Extra Verification Needed",
"We weren't able to auto-approve you for rewards. Please complete one of the steps below to unlock them.": "We weren't able to auto-approve you for rewards. Please complete one of the steps below to unlock them.",
"Proof via Text": "Proof via Text",
"Verify Phone Number": "Verify Phone Number",
"OR": "OR",
"Proof via Credit": "Proof via Credit",
"If you have a valid credit or debit card, you can use it to instantly prove your humanity. LBRY does not store your credit card information. There is no charge at all for this, now or in the future.": "If you have a valid credit or debit card, you can use it to instantly prove your humanity. LBRY does not store your credit card information. There is no charge at all for this, now or in the future.",
"Verify Card": "Verify Card",
"Read more": "Read more",
"Proof via Chat": "Proof via Chat",
"A moderator capable of approving you is typically available in the discord server. Check out the #rewards-approval channel for more information. This process will likely involve providing proof of a stable and established online or real-life identity.": "A moderator capable of approving you is typically available in the discord server. Check out the #rewards-approval channel for more information. This process will likely involve providing proof of a stable and established online or real-life identity.",
"We're friendly. We promise.": "We're friendly. We promise.",
"No Channels Created Yet": "No Channels Created Yet",
"Create A Channel": "Create A Channel",
"Wallet encryption is currently unavailable until it's supported for synced accounts. It will be added back soon. %learn_more%": "Wallet encryption is currently unavailable until it's supported for synced accounts. It will be added back soon. %learn_more%",
"Unsave Password": "Unsave Password",
"Clear Saved Password": "Clear Saved Password",
"Forget": "Forget",
"Nevermind": "Nevermind",
"You are about to delete your saved password.": "You are about to delete your saved password.",
"Your wallet will still be encrypted, but you will have to remember and enter it manually on startup.": "Your wallet will still be encrypted, but you will have to remember and enter it manually on startup.",
"A channel is your identity on the LBRY network.": "A channel is your identity on the LBRY network.",
"You can have more than one or change this later.": "You can have more than one or change this later.",
"Your Channel": "Your Channel",
"channel": "channel",
"Create": "Create"
}

View file

@ -6858,9 +6858,9 @@ lbry-redux@lbryio/lbry-redux#85fe532d69704a283fd2ec640ad6e3b8dacd6d0d:
reselect "^3.0.0"
uuid "^3.3.2"
lbryinc@lbryio/lbryinc#44b6373ada13299a0fba1e60ac508f485af75388:
lbryinc@lbryio/lbryinc#d1dba98bb6f1dc67bc0db4c0a20fc13b8a0de98b:
version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/44b6373ada13299a0fba1e60ac508f485af75388"
resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/d1dba98bb6f1dc67bc0db4c0a20fc13b8a0de98b"
dependencies:
reselect "^3.0.0"