Skip to content

Commit

Permalink
Fix missing resolve for purchase receipt
Browse files Browse the repository at this point in the history
## Reproduce
1. F5 to clear resolve cache.
2. Navigate to a channel that you have purchased something from.
3. Click on the claim that you know you have purchased. The app still asks you to purchase it.

## Root
We used to always call `resolve + include_purchase_receipt` when entering a File Page.
The embed/hoc refactoring skips that if the claim is already in cache, but that claim was resolved without `include_purchase_receipt` from step 2's search.

## Change
Retain existing optimization, but also double-check if the claim requires a fee. If yes, then re-fetch if we don't have the purchase receipt info.
  • Loading branch information
infinite-persistence committed Aug 24, 2023
1 parent a90b065 commit 99ff8f0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ui/hocs/withResolvedClaimRender/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ const withResolvedClaimRender = (ClaimRenderComponent: FunctionalComponentParam)
const claimIsRestricted =
!claimIsMine && (geoRestriction !== null || isClaimBlackListed || (isClaimFiltered && !preferEmbed));

const resolveRequired =
claim === undefined || (claim && claim.value?.fee && claim.purchase_receipt === undefined && isAuthenticated);

const isVisibilityRestricted = useIsVisibilityRestricted(
claim,
claimIsMine,
Expand Down Expand Up @@ -106,10 +109,10 @@ const withResolvedClaimRender = (ClaimRenderComponent: FunctionalComponentParam)
);

React.useEffect(() => {
if (hasClaim === undefined) {
if (resolveRequired) {
resolveClaim();
}
}, [hasClaim, resolveClaim]);
}, [resolveRequired, resolveClaim]);

if (!hasClaim) {
if (hasClaim === undefined) {
Expand Down

0 comments on commit 99ff8f0

Please sign in to comment.