updates supporting sync fixes

change alt preference key to local

remove enable_sync from sync list

restore to enable_sync in client settings
This commit is contained in:
jessop 2020-09-16 09:56:24 -04:00 committed by Sean Yesmunt
parent 3bfdde4629
commit 90012bf47c
3 changed files with 24 additions and 13 deletions

13
dist/bundle.es.js vendored
View file

@ -957,7 +957,7 @@ var daemon_settings = /*#__PURE__*/Object.freeze({
const SDK_SYNC_KEYS = [LBRYUM_SERVERS, SHARE_USAGE_DATA]; const SDK_SYNC_KEYS = [LBRYUM_SERVERS, SHARE_USAGE_DATA];
// CLIENT // CLIENT
const CLIENT_SYNC_KEYS = [SHOW_MATURE, HIDE_REPOSTS, SHOW_ANONYMOUS, INSTANT_PURCHASE_ENABLED, INSTANT_PURCHASE_MAX, THEME, AUTOPLAY, HIDE_BALANCE, HIDE_SPLASH_ANIMATION, FLOATING_PLAYER, DARK_MODE_TIMES, AUTOMATIC_DARK_MODE_ENABLED, ENABLE_SYNC]; const CLIENT_SYNC_KEYS = [SHOW_MATURE, HIDE_REPOSTS, SHOW_ANONYMOUS, INSTANT_PURCHASE_ENABLED, INSTANT_PURCHASE_MAX, THEME, AUTOPLAY, HIDE_BALANCE, HIDE_SPLASH_ANIMATION, FLOATING_PLAYER, DARK_MODE_TIMES, AUTOMATIC_DARK_MODE_ENABLED];
var shared_preferences = /*#__PURE__*/Object.freeze({ var shared_preferences = /*#__PURE__*/Object.freeze({
SDK_SYNC_KEYS: SDK_SYNC_KEYS, SDK_SYNC_KEYS: SDK_SYNC_KEYS,
@ -1801,7 +1801,10 @@ function doPreferenceGet(key, success, fail) {
const SHARED_PREFERENCE_VERSION = '0.1'; const SHARED_PREFERENCE_VERSION = '0.1';
let oldShared = {}; let oldShared = {};
const buildSharedStateMiddleware = (actions, sharedStateFilters, sharedStateCb) => ({ getState, dispatch }) => next => action => { const buildSharedStateMiddleware = (actions, sharedStateFilters, sharedStateCb) => ({
getState,
dispatch
}) => next => action => {
const currentState = getState(); const currentState = getState();
// We don't care if sync is disabled here, we always want to backup preferences to the wallet // We don't care if sync is disabled here, we always want to backup preferences to the wallet
@ -1812,7 +1815,9 @@ const buildSharedStateMiddleware = (actions, sharedStateFilters, sharedStateCb)
const actionResult = next(action); const actionResult = next(action);
// Call `getState` after calling `next` to ensure the state has updated in response to the action // Call `getState` after calling `next` to ensure the state has updated in response to the action
const nextState = getState(); const nextState = getState();
const preferenceKey = nextState.user && nextState.user.user && nextState.user.user.has_verified_email ? 'shared' : 'anon'; const syncEnabled = nextState.settings && nextState.settings.clientSettings && nextState.settings.clientSettings.enable_sync;
const hasVerifiedEmail = nextState.user && nextState.user.user && nextState.user.user.has_verified_email;
const preferenceKey = syncEnabled && hasVerifiedEmail ? 'shared' : 'local';
const shared = {}; const shared = {};
Object.keys(sharedStateFilters).forEach(key => { Object.keys(sharedStateFilters).forEach(key => {
@ -2782,7 +2787,7 @@ function doSendDraftTransaction(address, amount) {
type: SEND_TRANSACTION_COMPLETED type: SEND_TRANSACTION_COMPLETED
}); });
dispatch(doToast({ dispatch(doToast({
message: __(`You sent ${amount} LBRY Credits`), message: __('You sent %amount% LBRY Credits', { amount: amount }),
linkText: __('History'), linkText: __('History'),
linkTarget: '/wallet' linkTarget: '/wallet'
})); }));

View file

@ -27,5 +27,4 @@ export const CLIENT_SYNC_KEYS = [
SETTINGS.FLOATING_PLAYER, SETTINGS.FLOATING_PLAYER,
SETTINGS.DARK_MODE_TIMES, SETTINGS.DARK_MODE_TIMES,
SETTINGS.AUTOMATIC_DARK_MODE_ENABLED, SETTINGS.AUTOMATIC_DARK_MODE_ENABLED,
SETTINGS.ENABLE_SYNC,
]; ];

View file

@ -9,9 +9,13 @@ export const buildSharedStateMiddleware = (
actions: Array<string>, actions: Array<string>,
sharedStateFilters: {}, sharedStateFilters: {},
sharedStateCb?: any => void sharedStateCb?: any => void
) => ({ getState, dispatch }: { getState: () => { user: any }, dispatch: any => void }) => ( ) => ({
next: ({}) => void getState,
) => (action: { type: string, data: any }) => { dispatch,
}: {
getState: () => { user: any, settings: any },
dispatch: any => void,
}) => (next: ({}) => void) => (action: { type: string, data: any }) => {
const currentState = getState(); const currentState = getState();
// We don't care if sync is disabled here, we always want to backup preferences to the wallet // We don't care if sync is disabled here, we always want to backup preferences to the wallet
@ -21,11 +25,14 @@ export const buildSharedStateMiddleware = (
const actionResult = next(action); const actionResult = next(action);
// Call `getState` after calling `next` to ensure the state has updated in response to the action // Call `getState` after calling `next` to ensure the state has updated in response to the action
const nextState: { user: any } = getState(); const nextState: { user: any, settings: any } = getState();
const preferenceKey = const syncEnabled =
nextState.user && nextState.user.user && nextState.user.user.has_verified_email nextState.settings &&
? 'shared' nextState.settings.clientSettings &&
: 'anon'; nextState.settings.clientSettings.enable_sync;
const hasVerifiedEmail =
nextState.user && nextState.user.user && nextState.user.user.has_verified_email;
const preferenceKey = syncEnabled && hasVerifiedEmail ? 'shared' : 'local';
const shared = {}; const shared = {};
Object.keys(sharedStateFilters).forEach(key => { Object.keys(sharedStateFilters).forEach(key => {