Remove abandoned claim from Uploads Page (#7534)

## Issue
In Uploads Page, Claim doesn't go away immediately when deleted, only after a refresh.

## Approach
- Also update `myClaimsPageResults` when abandoning.
- `abandonedUris` is an array because the uris come in various form, so had to check all.

(Cherry-pick of Odysee PR_1276)
This commit is contained in:
infinite-persistence 2022-04-14 00:22:50 +08:00 committed by GitHub
parent daab8a28ed
commit 21204321c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -532,17 +532,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];
}
@ -560,6 +568,7 @@ reducers[ACTIONS.ABANDON_CLAIM_SUCCEEDED] = (state: State, action: any): State =
byId,
claimsByUri,
abandoningById,
myClaimsPageResults: myClaimsPageResults || state.myClaimsPageResults,
});
};