diff --git a/dist/bundle.es.js b/dist/bundle.es.js index fcedf9b..ee590eb 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1996,7 +1996,6 @@ function doPreferenceGet(key, success, fail) { // -const SHARED_PREFERENCE_KEY = 'shared'; const SHARED_PREFERENCE_VERSION = '0.1'; let oldShared = {}; @@ -2011,6 +2010,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 => { @@ -2027,7 +2027,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) { @@ -3235,11 +3235,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 + })); + }, 15000); + lbryProxy.wallet_reconnect().then(() => { + clearTimeout(walletTimeout); + if (!failed) dispatch({ type: WALLET_RESTART_COMPLETED }); + }); }; } function doWalletDecrypt() { diff --git a/src/redux/actions/wallet.js b/src/redux/actions/wallet.js index 949ada5..c454352 100644 --- a/src/redux/actions/wallet.js +++ b/src/redux/actions/wallet.js @@ -424,13 +424,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, + }) + ); + }, 15000); + 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) {