From f760f59dde7c5304bb4d0edda1de7fcbf7c1b02e Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Wed, 15 Aug 2018 14:17:38 -0400 Subject: [PATCH] handle new daemon status response --- dist/bundle.js | 18 +++++++----------- src/constants/action_types.js | 1 - src/redux/actions/wallet.js | 11 +++-------- src/redux/reducers/wallet.js | 2 +- 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/dist/bundle.js b/dist/bundle.js index 99cf246..43e1ad8 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -1596,7 +1596,6 @@ var WALLET_LOCK_COMPLETED = exports.WALLET_LOCK_COMPLETED = 'WALLET_LOCK_COMPLET var WALLET_LOCK_FAILED = exports.WALLET_LOCK_FAILED = 'WALLET_LOCK_FAILED'; var WALLET_STATUS_START = exports.WALLET_STATUS_START = 'WALLET_STATUS_START'; var WALLET_STATUS_COMPLETED = exports.WALLET_STATUS_COMPLETED = 'WALLET_STATUS_COMPLETED'; -var WALLET_STATUS_FAILED = exports.WALLET_STATUS_FAILED = 'WALLET_STATUS_FAILED'; // Claims var FETCH_FEATURED_CONTENT_STARTED = exports.FETCH_FEATURED_CONTENT_STARTED = 'FETCH_FEATURED_CONTENT_STARTED'; @@ -4192,6 +4191,7 @@ var DEFAULTSEARCHRESULTFROM = 0; var doSearch = exports.doSearch = function doSearch(rawQuery) { var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULTSEARCHRESULTSIZE; var from = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULTSEARCHRESULTFROM; + var isBackgroundSearch = arguments[3]; return function (dispatch, getState) { var state = getState(); var query = rawQuery.replace(/^lbry:\/\//i, ''); @@ -4216,7 +4216,8 @@ var doSearch = exports.doSearch = function doSearch(rawQuery) { // If the user is on the file page with a pre-populated uri and they select // the search option without typing anything, searchQuery will be empty // We need to populate it so the input is filled on the search page - if (!state.search.searchQuery) { + // isBackgroundSearch means the search is happening in the background, don't update the search query + if (!state.search.searchQuery && !isBackgroundSearch) { dispatch({ type: ACTIONS.UPDATE_SEARCH_QUERY, data: { searchQuery: query } @@ -4863,16 +4864,11 @@ function doWalletStatus() { type: ACTIONS.WALLET_STATUS_START }); - _lbry2.default.status().then(function (result) { - if (result && !result.error) { + _lbry2.default.status().then(function (status) { + if (status && status.wallet) { dispatch({ type: ACTIONS.WALLET_STATUS_COMPLETED, - result: result - }); - } else { - dispatch({ - type: ACTIONS.WALLET_STATUS_FAILED, - result: result + result: status.wallet.is_encrypted }); } }); @@ -6231,7 +6227,7 @@ reducers[ACTIONS.FETCH_BLOCK_SUCCESS] = function (state /*: WalletState*/, actio reducers[ACTIONS.WALLET_STATUS_COMPLETED] = function (state /*: WalletState*/, action) { return Object.assign({}, state, { - walletIsEncrypted: !!action.result.wallet_is_encrypted + walletIsEncrypted: action.result }); }; diff --git a/src/constants/action_types.js b/src/constants/action_types.js index 53d8129..f3497f6 100644 --- a/src/constants/action_types.js +++ b/src/constants/action_types.js @@ -57,7 +57,6 @@ export const WALLET_LOCK_COMPLETED = 'WALLET_LOCK_COMPLETED'; export const WALLET_LOCK_FAILED = 'WALLET_LOCK_FAILED'; export const WALLET_STATUS_START = 'WALLET_STATUS_START'; export const WALLET_STATUS_COMPLETED = 'WALLET_STATUS_COMPLETED'; -export const WALLET_STATUS_FAILED = 'WALLET_STATUS_FAILED'; // Claims export const FETCH_FEATURED_CONTENT_STARTED = 'FETCH_FEATURED_CONTENT_STARTED'; diff --git a/src/redux/actions/wallet.js b/src/redux/actions/wallet.js index f80fca3..e4609d3 100644 --- a/src/redux/actions/wallet.js +++ b/src/redux/actions/wallet.js @@ -337,16 +337,11 @@ export function doWalletStatus() { type: ACTIONS.WALLET_STATUS_START, }); - Lbry.status().then(result => { - if (result && !result.error) { + Lbry.status().then(status => { + if (status && status.wallet) { dispatch({ type: ACTIONS.WALLET_STATUS_COMPLETED, - result, - }); - } else { - dispatch({ - type: ACTIONS.WALLET_STATUS_FAILED, - result, + result: status.wallet.is_encrypted, }); } }); diff --git a/src/redux/reducers/wallet.js b/src/redux/reducers/wallet.js index c053810..8433104 100644 --- a/src/redux/reducers/wallet.js +++ b/src/redux/reducers/wallet.js @@ -188,7 +188,7 @@ reducers[ACTIONS.FETCH_BLOCK_SUCCESS] = (state: WalletState, action) => { reducers[ACTIONS.WALLET_STATUS_COMPLETED] = (state: WalletState, action) => Object.assign({}, state, { - walletIsEncrypted: !!action.result.wallet_is_encrypted, + walletIsEncrypted: action.result, }); reducers[ACTIONS.WALLET_ENCRYPT_START] = (state: WalletState) => -- 2.45.2