Remove abandoned claim from Uploads Page

## Issue
Ticket: 108

## Interesting
Uploads Page uses `claim_list`
Channel Page uses `claim_search

A second `claim_list` would instantly show updated results, but `claim_search` takes a long while to reflect the deletion.

## Change
This PR only handles the `claim_list` (Uploads Page).

The `claim_search` version would be troublesome to handle. If a refresh would bring back the results (due to the `claim_search` slow update behavior), we would need to store the deleted claim persistently. Then ...
  - Store where? rehydrate?
  - When to clear?
  - How to make each `ClaimList` filter this out without polluting the code? etc.
...will be messy. Feels easier to "fix" at the `claim_search` level to make it update faster (maybe a command to clear cache at server or something).
This commit is contained in:
infinite-persistence 2022-04-04 16:46:01 +08:00 committed by Thomas Zarebczan
parent 108b4a92a8
commit 79a093eb28

View file

@ -632,17 +632,25 @@ reducers[ACTIONS.ABANDON_CLAIM_SUCCEEDED] = (state: State, action: any): State =
const { claimId }: { claimId: string } = action.data;
const byId = Object.assign({}, state.byId);
const newMyClaims = state.myClaims ? state.myClaims.slice() : [];
let myClaimsPageResults = null;
const newMyChannelClaims = state.myChannelClaims ? state.myChannelClaims.slice() : [];
const claimsByUri = Object.assign({}, state.claimsByUri);
const abandoningById = Object.assign({}, state.abandoningById);
const newMyCollectionClaims = state.myCollectionClaims ? state.myCollectionClaims.slice() : [];
let abandonedUris = [];
Object.keys(claimsByUri).forEach((uri) => {
if (claimsByUri[uri] === claimId) {
abandonedUris.push(uri);
delete claimsByUri[uri];
}
});
if (abandonedUris.length > 0 && state.myClaimsPageResults) {
myClaimsPageResults = state.myClaimsPageResults.filter((uri) => !abandonedUris.includes(uri));
}
if (abandoningById[claimId]) {
delete abandoningById[claimId];
}
@ -660,6 +668,7 @@ reducers[ACTIONS.ABANDON_CLAIM_SUCCEEDED] = (state: State, action: any): State =
byId,
claimsByUri,
abandoningById,
myClaimsPageResults: myClaimsPageResults || state.myClaimsPageResults,
});
};