From f1c45775ab33b48f88eed0b41bd872035c7e7ecf Mon Sep 17 00:00:00 2001 From: 6ea86b96 <6ea86b96@gmail.com> Date: Tue, 11 Jul 2017 15:30:28 +0700 Subject: [PATCH] Cleaner way of filtering published claims while abandoning --- ui/js/actions/file_info.js | 18 +++++------------- ui/js/reducers/claims.js | 8 ++++++-- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/ui/js/actions/file_info.js b/ui/js/actions/file_info.js index b36cb784e..d21df8d2a 100644 --- a/ui/js/actions/file_info.js +++ b/ui/js/actions/file_info.js @@ -102,20 +102,12 @@ export function doDeleteFile(outpoint, deleteFromComputer, abandonClaim) { }, }); - // We need to run this after a few seconds or the claim gets added back - // to the store again by an already running fetch claims query. - const success = setTimeout( - () => { - dispatch({ - type: types.ABANDON_CLAIM_SUCCEEDED, - data: { - claimId: fileInfo.claim_id, - }, - }); + const success = dispatch({ + type: types.ABANDON_CLAIM_SUCCEEDED, + data: { + claimId: fileInfo.claim_id, }, - 10000, - { once: true } - ); + }); lbry.claim_abandon({ claim_id: fileInfo.claim_id }).then(success); } } diff --git a/ui/js/reducers/claims.js b/ui/js/reducers/claims.js index adc0eb2ed..9e072f1ce 100644 --- a/ui/js/reducers/claims.js +++ b/ui/js/reducers/claims.js @@ -43,8 +43,12 @@ reducers[types.FETCH_CLAIM_LIST_MINE_COMPLETED] = function(state, action) { const byUri = Object.assign({}, state.claimsByUri); const byId = Object.assign({}, state.byId); const pendingById = Object.assign({}, state.pendingById); - - const myClaims = new Set(claims.map(claim => claim.claim_id)); + const abandoningById = Object.assign({}, state.abandoningById); + const myClaims = new Set( + claims + .map(claim => claim.claim_id) + .filter(claimId => Object.keys(abandoningById).indexOf(claimId) === -1) + ); claims.forEach(claim => { byId[claim.claim_id] = claim;