| 58 | export const showCertFetchStateSelector = state => |
| 59 | state[MainApp].showCertFetchState; |
| 60 | export const shouldRequestDonationSelector = state => { |
| 61 | const completedChallengeCount = completedChallengesSelector(state).length; |
| 62 | const isDonating = isDonatingSelector(state); |
| 63 | const donatableSectionRecentlyCompleted = |
| 64 | donatableSectionRecentlyCompletedSelector(state); |
| 65 | const isRandomCompletionThreshold = |
| 66 | isRandomCompletionThresholdSelector(state); |
| 67 | |
| 68 | // don't request donation if already donating |
| 69 | if (isDonating) return false; |
| 70 | |
| 71 | // donations only appear after the user has completed ten challenges (i.e. |
| 72 | // not before the 11th challenge has mounted) |
| 73 | if (completedChallengeCount < 10) return false; |
| 74 | |
| 75 | // a block or module has been completed |
| 76 | if (donatableSectionRecentlyCompleted) return true; |
| 77 | |
| 78 | const sessionChallengeData = getSessionChallengeData(); |
| 79 | /* |
| 80 | Different intervals need to be tested for optimization. |
| 81 | */ |
| 82 | // the assumption is that we save the count when we request donations |
| 83 | if (sessionChallengeData.isSaved) { |
| 84 | // only request if sufficient challenges have been completed since last |
| 85 | // request |
| 86 | return sessionChallengeData.countSinceSave >= 20; |
| 87 | } |
| 88 | |
| 89 | /* |
| 90 | Show modal if user has completed 10 challanged in total |
| 91 | and 3 or more in this session. |
| 92 | The isRandomCompletionThreshold flag is used to AB test interval randomness |
| 93 | */ |
| 94 | if (isRandomCompletionThreshold) { |
| 95 | return sessionChallengeData.currentCount >= randomBetween(3, 7); |
| 96 | } else { |
| 97 | return sessionChallengeData.currentCount >= 3; |
| 98 | } |
| 99 | }; |
| 100 | |
| 101 | export const userTokenSelector = state => userSelector(state)?.userToken; |
| 102 |
nothing calls this directly
no test coverage detected