diff --git a/dist/bundle.es.js b/dist/bundle.es.js index d064928..e98f81f 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -965,7 +965,7 @@ var daemon_settings = /*#__PURE__*/Object.freeze({ const SDK_SYNC_KEYS = [LBRYUM_SERVERS, SHARE_USAGE_DATA]; // CLIENT -const CLIENT_SYNC_KEYS = [SHOW_MATURE, HIDE_REPOSTS, SHOW_ANONYMOUS, INSTANT_PURCHASE_ENABLED, INSTANT_PURCHASE_MAX, THEME, THEMES, AUTOPLAY, HIDE_BALANCE, HIDE_SPLASH_ANIMATION, FLOATING_PLAYER, DARK_MODE_TIMES, AUTOMATIC_DARK_MODE_ENABLED]; +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]; /* @@ -2005,7 +2005,6 @@ function doPreferenceGet(key, success, fail) { // -const SHARED_PREFERENCE_KEY = 'shared'; const SHARED_PREFERENCE_VERSION = '0.1'; let oldShared = {}; @@ -2020,6 +2019,7 @@ const buildSharedStateMiddleware = (actions, sharedStateFilters, sharedStateCb) const actionResult = next(action); // Call `getState` after calling `next` to ensure the state has updated in response to the action const nextState = getState(); + const preferenceKey = nextState.user && nextState.user.user && nextState.user.user.has_verified_email ? 'shared' : 'anon'; const shared = {}; Object.keys(sharedStateFilters).forEach(key => { @@ -2036,7 +2036,7 @@ const buildSharedStateMiddleware = (actions, sharedStateFilters, sharedStateCb) if (!isEqual(oldShared, shared)) { // only update if the preference changed from last call in the same session oldShared = shared; - doPreferenceSet(SHARED_PREFERENCE_KEY, shared, SHARED_PREFERENCE_VERSION); + doPreferenceSet(preferenceKey, shared, SHARED_PREFERENCE_VERSION); } if (sharedStateCb) { @@ -2879,6 +2879,7 @@ function creditsToString(amount) { var _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; +const FIFTEEN_SECONDS = 15000; let walletBalancePromise = null; function doUpdateBalance() { return (dispatch, getState) => { @@ -3244,11 +3245,23 @@ function doWalletReconnect() { dispatch({ type: WALLET_RESTART }); + let failed = false; // this basically returns null when it's done. :( // might be good to dispatch ACTIONS.WALLET_RESTARTED - lbryProxy.wallet_reconnect().then(() => dispatch({ - type: WALLET_RESTART_COMPLETED - })); + const walletTimeout = setTimeout(() => { + failed = true; + dispatch({ + type: WALLET_RESTART_COMPLETED + }); + dispatch(doToast({ + message: __('Your servers were not available. Check your url and port, or switch back to defaults.'), + isError: true + })); + }, FIFTEEN_SECONDS); + lbryProxy.wallet_reconnect().then(() => { + clearTimeout(walletTimeout); + if (!failed) dispatch({ type: WALLET_RESTART_COMPLETED }); + }); }; } function doWalletDecrypt() { diff --git a/src/constants/shared_preferences.js b/src/constants/shared_preferences.js index 1c28aff..7257214 100644 --- a/src/constants/shared_preferences.js +++ b/src/constants/shared_preferences.js @@ -21,7 +21,6 @@ export const CLIENT_SYNC_KEYS = [ SETTINGS.INSTANT_PURCHASE_ENABLED, SETTINGS.INSTANT_PURCHASE_MAX, SETTINGS.THEME, - SETTINGS.THEMES, SETTINGS.AUTOPLAY, SETTINGS.HIDE_BALANCE, SETTINGS.HIDE_SPLASH_ANIMATION, diff --git a/src/redux/actions/wallet.js b/src/redux/actions/wallet.js index 00d2b0c..92c66f4 100644 --- a/src/redux/actions/wallet.js +++ b/src/redux/actions/wallet.js @@ -10,6 +10,7 @@ import { creditsToString } from 'util/format-credits'; import { selectMyClaimsRaw } from 'redux/selectors/claims'; import { doFetchChannelListMine, doFetchClaimListMine } from 'redux/actions/claims'; +const FIFTEEN_SECONDS = 15000; let walletBalancePromise = null; export function doUpdateBalance() { return (dispatch, getState) => { @@ -421,13 +422,27 @@ export function doWalletReconnect() { dispatch({ type: ACTIONS.WALLET_RESTART, }); + let failed = false; // this basically returns null when it's done. :( // might be good to dispatch ACTIONS.WALLET_RESTARTED - Lbry.wallet_reconnect().then(() => + const walletTimeout = setTimeout(() => { + failed = true; dispatch({ type: ACTIONS.WALLET_RESTART_COMPLETED, - }) - ); + }); + dispatch( + doToast({ + message: __( + 'Your servers were not available. Check your url and port, or switch back to defaults.' + ), + isError: true, + }) + ); + }, FIFTEEN_SECONDS); + Lbry.wallet_reconnect().then(() => { + clearTimeout(walletTimeout); + if (!failed) dispatch({ type: ACTIONS.WALLET_RESTART_COMPLETED }); + }); }; } export function doWalletDecrypt() { diff --git a/src/redux/middleware/shared-state.js b/src/redux/middleware/shared-state.js index 0fb0d7f..100a86c 100644 --- a/src/redux/middleware/shared-state.js +++ b/src/redux/middleware/shared-state.js @@ -2,7 +2,6 @@ import isEqual from 'util/deep-equal'; import { doPreferenceSet } from 'redux/actions/sync'; -const SHARED_PREFERENCE_KEY = 'shared'; const SHARED_PREFERENCE_VERSION = '0.1'; let oldShared = {}; @@ -10,7 +9,7 @@ export const buildSharedStateMiddleware = ( actions: Array, sharedStateFilters: {}, sharedStateCb?: any => void -) => ({ getState, dispatch }: { getState: () => {}, dispatch: any => void }) => ( +) => ({ getState, dispatch }: { getState: () => { user: any }, dispatch: any => void }) => ( next: ({}) => void ) => (action: { type: string, data: any }) => { const currentState = getState(); @@ -22,7 +21,11 @@ export const buildSharedStateMiddleware = ( const actionResult = next(action); // Call `getState` after calling `next` to ensure the state has updated in response to the action - const nextState = getState(); + const nextState: { user: any } = getState(); + const preferenceKey = + nextState.user && nextState.user.user && nextState.user.user.has_verified_email + ? 'shared' + : 'anon'; const shared = {}; Object.keys(sharedStateFilters).forEach(key => { @@ -39,7 +42,7 @@ export const buildSharedStateMiddleware = ( if (!isEqual(oldShared, shared)) { // only update if the preference changed from last call in the same session oldShared = shared; - doPreferenceSet(SHARED_PREFERENCE_KEY, shared, SHARED_PREFERENCE_VERSION); + doPreferenceSet(preferenceKey, shared, SHARED_PREFERENCE_VERSION); } if (sharedStateCb) {