Assume weekly_watch is claimed when data is insufficient (#1806)

## Issue
If the reward-list fetch is slow, the selector assumes the weekly_watch hasn't been claimed yet, causing an unnecessary claim.

## Change
The selector now tells the caller if there is no data -- up to caller on what to do (in this case, don't claim the reward).

It should be harmless if the claim action was missed, since the user can still manually claim it.
This commit is contained in:
infinite-persistence 2022-07-07 17:16:36 +08:00 committed by GitHub
parent e073e120a1
commit da691f286e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -144,7 +144,7 @@ export function doClaimEligiblePurchaseRewards() {
if (unclaimedRewards.find((ur) => ur.reward_type === rewards.TYPE_FIRST_STREAM)) {
dispatch(doClaimRewardType(rewards.TYPE_FIRST_STREAM));
} else {
if (!selectWeeklyWatchClaimedThisWeek(state)) {
if (selectWeeklyWatchClaimedThisWeek(state) === false) {
dispatch(doClaimRewardType(rewards.TYPE_WEEKLY_WATCH, { failSilently: true }));
}
}

View file

@ -80,7 +80,7 @@ export const selectWeeklyWatchClaimedThisWeek = createSelector(selectUnclaimedRe
const diffDays = diff / (1000 * 60 * 60 * 24);
return diffDays < 6.5;
}
return false;
return undefined;
});
export const selectIsRewardApproved = createSelector(selectUser, (user) => user && user.is_reward_approved);