call preference get after entering wallet password
This commit is contained in:
parent
4d3bdda55c
commit
d301102af6
4 changed files with 24 additions and 25 deletions
|
@ -1,7 +1,7 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { doGetSync, selectGetSyncIsPending, selectUserEmail, selectSyncApplyPasswordError } from 'lbryinc';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { doSignOut } from 'redux/actions/app';
|
||||
import { doSignOut, doHandleSyncComplete } from 'redux/actions/app';
|
||||
import SyncPassword from './view';
|
||||
|
||||
const select = state => ({
|
||||
|
@ -13,10 +13,8 @@ const select = state => ({
|
|||
const perform = dispatch => ({
|
||||
getSync: (password, cb) => dispatch(doGetSync(password, cb)),
|
||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||
handleSyncComplete: (error, hasDataChanged) => dispatch(doHandleSyncComplete(error, hasDataChanged)),
|
||||
signOut: () => dispatch(doSignOut()),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
perform
|
||||
)(SyncPassword);
|
||||
export default connect(select, perform)(SyncPassword);
|
||||
|
|
|
@ -8,20 +8,23 @@ import usePersistedState from 'effects/use-persisted-state';
|
|||
import I18nMessage from 'component/i18nMessage';
|
||||
|
||||
type Props = {
|
||||
getSync: (?string, (any) => void) => void,
|
||||
getSync: (?string, (any, boolean) => void) => void,
|
||||
getSyncIsPending: boolean,
|
||||
email: string,
|
||||
passwordError: boolean,
|
||||
signOut: () => void,
|
||||
handleSyncComplete: (any, boolean) => void,
|
||||
};
|
||||
|
||||
function SyncPassword(props: Props) {
|
||||
const { getSync, getSyncIsPending, email, signOut, passwordError } = props;
|
||||
const { getSync, getSyncIsPending, email, signOut, passwordError, handleSyncComplete } = props;
|
||||
const [password, setPassword] = React.useState('');
|
||||
const [rememberPassword, setRememberPassword] = usePersistedState(true);
|
||||
|
||||
function handleSubmit() {
|
||||
getSync(password, error => {
|
||||
getSync(password, (error, hasDataChanged) => {
|
||||
handleSyncComplete(error, hasDataChanged);
|
||||
|
||||
if (!error) {
|
||||
setSavedPassword(password, rememberPassword);
|
||||
}
|
||||
|
|
12
ui/index.jsx
12
ui/index.jsx
|
@ -31,7 +31,7 @@ import {
|
|||
doAuthTokenRefresh,
|
||||
} from 'util/saved-passwords';
|
||||
import { X_LBRY_AUTH_TOKEN } from 'constants/token';
|
||||
import { LBRY_WEB_API } from 'config';
|
||||
import { LBRY_WEB_API, DEFAULT_LANGUAGE } from 'config';
|
||||
|
||||
// Import our app styles
|
||||
// If a style is not necessary for the initial page load, it should be removed from `all.scss`
|
||||
|
@ -41,7 +41,6 @@ import 'scss/all.scss';
|
|||
// @if TARGET='web'
|
||||
// These overrides can't live in web/ because they need to use the same instance of `Lbry`
|
||||
import apiPublishCallViaWeb from 'web/setup/publish';
|
||||
const { DEFAULT_LANGUAGE } = require('../config.js');
|
||||
|
||||
// Sentry error logging setup
|
||||
// Will only work if you have a SENTRY_AUTH_TOKEN env
|
||||
|
@ -242,7 +241,7 @@ document.addEventListener('click', event => {
|
|||
|
||||
function AppWrapper() {
|
||||
// Splash screen and sdk setup not needed on web
|
||||
const [readyToLaunch, setReadyToLaunch] = useState(IS_WEB || sessionStorage.getItem('startup'));
|
||||
const [readyToLaunch, setReadyToLaunch] = useState(IS_WEB);
|
||||
const [persistDone, setPersistDone] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -276,11 +275,8 @@ function AppWrapper() {
|
|||
|
||||
useEffect(() => {
|
||||
if (readyToLaunch && persistDone) {
|
||||
// @if TARGET='app'
|
||||
sessionStorage.setItem('startup', true);
|
||||
// @endif
|
||||
if (process.env.DEFAULT_LANGUAGE) {
|
||||
app.store.dispatch(doFetchLanguage(process.env.DEFAULT_LANGUAGE));
|
||||
if (DEFAULT_LANGUAGE) {
|
||||
app.store.dispatch(doFetchLanguage(DEFAULT_LANGUAGE));
|
||||
}
|
||||
app.store.dispatch(doUpdateIsNightAsync());
|
||||
app.store.dispatch(doDaemonReady());
|
||||
|
|
|
@ -586,23 +586,25 @@ export function doGetAndPopulatePreferences() {
|
|||
};
|
||||
}
|
||||
|
||||
export function doSyncWithPreferences() {
|
||||
export function doHandleSyncComplete(error, hasNewData) {
|
||||
return dispatch => {
|
||||
function handleSyncComplete(error, hasNewData) {
|
||||
if (!error) {
|
||||
dispatch(doGetAndPopulatePreferences());
|
||||
if (!error) {
|
||||
dispatch(doGetAndPopulatePreferences());
|
||||
|
||||
if (hasNewData) {
|
||||
// we just got sync data, better update our channels
|
||||
dispatch(doFetchChannelListMine());
|
||||
}
|
||||
if (hasNewData) {
|
||||
// we just got sync data, better update our channels
|
||||
dispatch(doFetchChannelListMine());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function doSyncWithPreferences() {
|
||||
return dispatch => {
|
||||
return getSavedPassword().then(password => {
|
||||
const passwordArgument = password === null ? '' : password;
|
||||
|
||||
dispatch(doGetSync(passwordArgument, handleSyncComplete));
|
||||
dispatch(doGetSync(passwordArgument, (error, hasNewData) => dispatch(doHandleSyncComplete(error, hasNewData))));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue