({ notifyExpiry = false } = {})
| 135 | } |
| 136 | |
| 137 | async function refreshState({ notifyExpiry = false } = {}) { |
| 138 | try { |
| 139 | const nextState = normalizeStatus(await secureAdRewardState.getStatus()); |
| 140 | state = nextState; |
| 141 | emitChange(); |
| 142 | scheduleExpiryCheck(); |
| 143 | |
| 144 | if (notifyExpiry && nextState.hasPendingExpiryNotice) { |
| 145 | notify( |
| 146 | "Ad-free pass ended", |
| 147 | "Your rewarded ad-free time has expired. You can watch another rewarded ad anytime.", |
| 148 | "warning", |
| 149 | ); |
| 150 | } |
| 151 | |
| 152 | return nextState; |
| 153 | } catch (error) { |
| 154 | console.warn("Failed to refresh rewarded ad state.", error); |
| 155 | return state; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | function scheduleExpiryCheck() { |
| 160 | clearExpiryTimer(); |
no test coverage detected