From 8093d69807d890f4110be0b2aa629e3df5945661 Mon Sep 17 00:00:00 2001 From: infiinte-persistence Date: Tue, 10 Nov 2020 01:05:53 +0800 Subject: [PATCH] claim_search: Don't clear previous page results if subsequent pages timeout. ## Issue https://github.com/lbryio/lbry-desktop/issues/4609 ## Change - Don't clear existing results on timeout. - Treat this scenario as "last page reached" by marking `claimSearchByQueryLastPageReached`. --- dist/bundle.es.js | 11 +++++++++-- src/redux/reducers/claims.js | 9 ++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 57ffe1d..071869d 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -5155,13 +5155,20 @@ reducers[CLAIM_SEARCH_FAILED] = (state, action) => { const { query } = action.data; const claimSearchByQuery = Object.assign({}, state.claimSearchByQuery); const fetchingClaimSearchByQuery = Object.assign({}, state.fetchingClaimSearchByQuery); + const claimSearchByQueryLastPageReached = Object.assign({}, state.claimSearchByQueryLastPageReached); delete fetchingClaimSearchByQuery[query]; - claimSearchByQuery[query] = null; + + if (claimSearchByQuery[query] && claimSearchByQuery[query].length !== 0) { + claimSearchByQueryLastPageReached[query] = true; + } else { + claimSearchByQuery[query] = null; + } return Object.assign({}, state, { fetchingClaimSearchByQuery, - claimSearchByQuery + claimSearchByQuery, + claimSearchByQueryLastPageReached }); }; diff --git a/src/redux/reducers/claims.js b/src/redux/reducers/claims.js index ecfa9d8..7582a9e 100644 --- a/src/redux/reducers/claims.js +++ b/src/redux/reducers/claims.js @@ -570,13 +570,20 @@ reducers[ACTIONS.CLAIM_SEARCH_FAILED] = (state: State, action: any): State => { const { query } = action.data; const claimSearchByQuery = Object.assign({}, state.claimSearchByQuery); const fetchingClaimSearchByQuery = Object.assign({}, state.fetchingClaimSearchByQuery); + const claimSearchByQueryLastPageReached = Object.assign({}, state.claimSearchByQueryLastPageReached); delete fetchingClaimSearchByQuery[query]; - claimSearchByQuery[query] = null; + + if (claimSearchByQuery[query] && claimSearchByQuery[query].length !== 0) { + claimSearchByQueryLastPageReached[query] = true; + } else { + claimSearchByQuery[query] = null; + } return Object.assign({}, state, { fetchingClaimSearchByQuery, claimSearchByQuery, + claimSearchByQueryLastPageReached, }); };