bugfix
This commit is contained in:
parent
6c4842a111
commit
b5dccced6d
6 changed files with 41 additions and 26 deletions
|
@ -12,7 +12,7 @@ import {
|
||||||
selectThemePath,
|
selectThemePath,
|
||||||
} from 'redux/selectors/settings';
|
} from 'redux/selectors/settings';
|
||||||
import { selectIsUpgradeAvailable, selectAutoUpdateDownloaded } from 'redux/selectors/app';
|
import { selectIsUpgradeAvailable, selectAutoUpdateDownloaded } from 'redux/selectors/app';
|
||||||
import { doSetLanguage, doUpdateSyncPref } from 'redux/actions/settings';
|
import { doSetLanguage, doUpdateSyncPrefIfFalse } from 'redux/actions/settings';
|
||||||
import { doSyncSubscribe } from 'redux/actions/syncwrapper';
|
import { doSyncSubscribe } from 'redux/actions/syncwrapper';
|
||||||
import {
|
import {
|
||||||
doDownloadUpgradeRequested,
|
doDownloadUpgradeRequested,
|
||||||
|
@ -46,7 +46,7 @@ const perform = dispatch => ({
|
||||||
signIn: () => dispatch(doSignIn()),
|
signIn: () => dispatch(doSignIn()),
|
||||||
requestDownloadUpgrade: () => dispatch(doDownloadUpgradeRequested()),
|
requestDownloadUpgrade: () => dispatch(doDownloadUpgradeRequested()),
|
||||||
updatePreferences: () => dispatch(doGetAndPopulatePreferences()),
|
updatePreferences: () => dispatch(doGetAndPopulatePreferences()),
|
||||||
updateSyncPref: () => dispatch(doUpdateSyncPref()),
|
pushPrefsIfSyncFalse: () => dispatch(doUpdateSyncPrefIfFalse()),
|
||||||
syncSubscribe: () => dispatch(doSyncSubscribe()),
|
syncSubscribe: () => dispatch(doSyncSubscribe()),
|
||||||
setReferrer: (referrer, doClaim) => dispatch(doUserSetReferrer(referrer, doClaim)),
|
setReferrer: (referrer, doClaim) => dispatch(doUserSetReferrer(referrer, doClaim)),
|
||||||
});
|
});
|
||||||
|
|
|
@ -67,7 +67,7 @@ type Props = {
|
||||||
isUpgradeAvailable: boolean,
|
isUpgradeAvailable: boolean,
|
||||||
autoUpdateDownloaded: boolean,
|
autoUpdateDownloaded: boolean,
|
||||||
updatePreferences: () => Promise<any>,
|
updatePreferences: () => Promise<any>,
|
||||||
updateSyncPref: () => void,
|
pushPrefsIfSyncFalse: () => void,
|
||||||
uploadCount: number,
|
uploadCount: number,
|
||||||
balance: ?number,
|
balance: ?number,
|
||||||
syncError: ?string,
|
syncError: ?string,
|
||||||
|
@ -99,7 +99,7 @@ function App(props: Props) {
|
||||||
languages,
|
languages,
|
||||||
setLanguage,
|
setLanguage,
|
||||||
updatePreferences,
|
updatePreferences,
|
||||||
updateSyncPref,
|
pushPrefsIfSyncFalse,
|
||||||
rewards,
|
rewards,
|
||||||
setReferrer,
|
setReferrer,
|
||||||
isAuthenticated,
|
isAuthenticated,
|
||||||
|
@ -237,6 +237,7 @@ function App(props: Props) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (updatePreferences && readyForPrefs) {
|
if (updatePreferences && readyForPrefs) {
|
||||||
updatePreferences().then(() => {
|
updatePreferences().then(() => {
|
||||||
|
// will pull and U_S_P; usp will make sure prefBox applied if false
|
||||||
setReadyForSync(true);
|
setReadyForSync(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -245,19 +246,21 @@ function App(props: Props) {
|
||||||
|
|
||||||
// ready for sync syncs, however after signin when hasVerifiedEmail, that syncs too.
|
// ready for sync syncs, however after signin when hasVerifiedEmail, that syncs too.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (readyForSync && hasVerifiedEmail) {
|
// signInSyncPref is cleared after sharedState loop.
|
||||||
// Copy sync checkbox to settings and push to preferences
|
if (readyForSync && hasVerifiedEmail && signInSyncPref === undefined) {
|
||||||
// before sync if false, after sync if true so as not to change timestamp.
|
// On sign-in, we get and apply all the information on whether to sync
|
||||||
if (signInSyncPref === false) {
|
// the checkbox, previous wallet settings, store rehydrate, etc
|
||||||
updateSyncPref();
|
// Our app is up to date with the wallet
|
||||||
}
|
// Because the checkbox is applied last, make sure the wallet remembers if false:
|
||||||
|
// @if TARGET='app'
|
||||||
|
pushPrefsIfSyncFalse();
|
||||||
|
// @endif
|
||||||
|
|
||||||
|
// And try this in case we are syncing.
|
||||||
syncSubscribe();
|
syncSubscribe();
|
||||||
if (signInSyncPref === true) {
|
|
||||||
updateSyncPref();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [readyForSync, hasVerifiedEmail, signInSyncPref, updateSyncPref, syncSubscribe]);
|
}, [readyForSync, hasVerifiedEmail, signInSyncPref, pushPrefsIfSyncFalse, syncSubscribe]);
|
||||||
|
|
||||||
// We know someone is logging in or not when we get their user object {}
|
// We know someone is logging in or not when we get their user object {}
|
||||||
// We'll use this to determine when it's time to pull preferences
|
// We'll use this to determine when it's time to pull preferences
|
||||||
|
|
|
@ -138,13 +138,14 @@ export function doSetClientSetting(key, value, pushPrefs) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doUpdateSyncPref() {
|
export function doUpdateSyncPrefIfFalse() {
|
||||||
|
// This is only called after manual signin to update the wallet
|
||||||
|
// that the sync preference is false
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const { settings } = getState();
|
const state = getState();
|
||||||
const { syncEnabledPref } = settings || {};
|
const syncEnabled = makeSelectClientSetting(SETTINGS.ENABLE_SYNC)(state);
|
||||||
if (syncEnabledPref !== undefined) {
|
if (syncEnabled === false) {
|
||||||
dispatch(doSetClientSetting(SETTINGS.ENABLE_SYNC, syncEnabledPref, true));
|
dispatch(doPushSettingsToPrefs());
|
||||||
dispatch(doSetSyncPref(undefined));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -224,6 +225,7 @@ export function doExitSettingsPage() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch(doSetSyncLock(false));
|
dispatch(doSetSyncLock(false));
|
||||||
dispatch(doPushSettingsToPrefs());
|
dispatch(doPushSettingsToPrefs());
|
||||||
|
// syncSubscribe is restarted in store.js sharedStateCB if necessary
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { doGetSync, selectGetSyncIsPending, selectSetSyncIsPending } from 'lbryinc';
|
import { doGetSync, selectGetSyncIsPending, selectSetSyncIsPending } from 'lbryinc';
|
||||||
import { SETTINGS } from 'lbry-redux';
|
import { SETTINGS } from 'lbry-redux';
|
||||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
import { makeSelectClientSetting, selectSyncSigninPref } from 'redux/selectors/settings';
|
||||||
import { getSavedPassword } from 'util/saved-passwords';
|
import { getSavedPassword } from 'util/saved-passwords';
|
||||||
import { doAnalyticsTagSync, doHandleSyncComplete } from 'redux/actions/app';
|
import { doAnalyticsTagSync, doHandleSyncComplete } from 'redux/actions/app';
|
||||||
import { selectSyncIsLocked } from 'redux/selectors/app';
|
import { selectSyncIsLocked } from 'redux/selectors/app';
|
||||||
|
@ -31,9 +31,10 @@ export function doSyncSubscribe() {
|
||||||
if (syncTimer) clearInterval(syncTimer);
|
if (syncTimer) clearInterval(syncTimer);
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const hasVerifiedEmail = selectUserVerifiedEmail(state);
|
const hasVerifiedEmail = selectUserVerifiedEmail(state);
|
||||||
|
const signInSyncPref = selectSyncSigninPref(state);
|
||||||
const syncEnabled = makeSelectClientSetting(SETTINGS.ENABLE_SYNC)(state);
|
const syncEnabled = makeSelectClientSetting(SETTINGS.ENABLE_SYNC)(state);
|
||||||
const syncLocked = selectSyncIsLocked(state);
|
const syncLocked = selectSyncIsLocked(state);
|
||||||
if (hasVerifiedEmail && syncEnabled && !syncLocked) {
|
if (hasVerifiedEmail && syncEnabled && !syncLocked && signInSyncPref !== false) {
|
||||||
dispatch(doGetSyncDesktop((error, hasNewData) => dispatch(doHandleSyncComplete(error, hasNewData))));
|
dispatch(doGetSyncDesktop((error, hasNewData) => dispatch(doHandleSyncComplete(error, hasNewData))));
|
||||||
dispatch(doAnalyticsTagSync());
|
dispatch(doAnalyticsTagSync());
|
||||||
syncTimer = setInterval(() => {
|
syncTimer = setInterval(() => {
|
||||||
|
|
|
@ -160,13 +160,22 @@ reducers[ACTIONS.SYNC_PREFERENCE_CHANGED] = (state, action) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[LBRY_REDUX_ACTIONS.USER_STATE_POPULATE] = (state, action) => {
|
reducers[LBRY_REDUX_ACTIONS.USER_STATE_POPULATE] = (state, action) => {
|
||||||
const { clientSettings: currentClientSettings } = state;
|
const { clientSettings: currentClientSettings, syncEnabledPref } = state;
|
||||||
const { settings: sharedPreferences } = action.data;
|
const { settings: sharedPreferences } = action.data;
|
||||||
|
// we have to update the signin sync checkbox in here
|
||||||
|
// where we can simulataneously set the checkbox temp value to undefined, and
|
||||||
|
// update the sync setting before sync happens
|
||||||
|
// temp box must be undefined to trigger the items in the syncSubscribe effect
|
||||||
|
const syncSettingOrEmpty = syncEnabledPref !== undefined ? { enable_sync: syncEnabledPref } : {};
|
||||||
|
|
||||||
const selectedSettings = sharedPreferences ? getSubsetFromKeysArray(sharedPreferences, clientSyncKeys) : {};
|
const selectedSettings = sharedPreferences ? getSubsetFromKeysArray(sharedPreferences, clientSyncKeys) : {};
|
||||||
const mergedClientSettings = { ...currentClientSettings, ...selectedSettings };
|
const mergedClientSettings = { ...currentClientSettings, ...selectedSettings, ...syncSettingOrEmpty };
|
||||||
const newSharedPreferences = sharedPreferences || {};
|
const newSharedPreferences = sharedPreferences || {};
|
||||||
return Object.assign({}, state, { sharedPreferences: newSharedPreferences, clientSettings: mergedClientSettings });
|
return Object.assign({}, state, {
|
||||||
|
sharedPreferences: newSharedPreferences,
|
||||||
|
clientSettings: mergedClientSettings,
|
||||||
|
syncEnabledPref: undefined,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[LBRY_REDUX_ACTIONS.SAVE_CUSTOM_WALLET_SERVERS] = (state, action) => {
|
reducers[LBRY_REDUX_ACTIONS.SAVE_CUSTOM_WALLET_SERVERS] = (state, action) => {
|
||||||
|
|
|
@ -11,7 +11,7 @@ export const selectFfmpegStatus = createSelector(selectDaemonStatus, status => s
|
||||||
|
|
||||||
export const selectFindingFFmpeg = createSelector(selectState, state => state.findingFFmpeg || false);
|
export const selectFindingFFmpeg = createSelector(selectState, state => state.findingFFmpeg || false);
|
||||||
|
|
||||||
export const selectSyncSigninPref = createSelector(selectState, state => state.syncEnabledPref || undefined);
|
export const selectSyncSigninPref = createSelector(selectState, state => state.syncEnabledPref);
|
||||||
|
|
||||||
export const selectClientSettings = createSelector(selectState, state => state.clientSettings || {});
|
export const selectClientSettings = createSelector(selectState, state => state.clientSettings || {});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue