MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / refreshState

Function refreshState

src/lib/adRewards.js:137–157  ·  view source on GitHub ↗
({ notifyExpiry = false } = {})

Source from the content-addressed store, hash-verified

135}
136
137async 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
159function scheduleExpiryCheck() {
160 clearExpiryTimer();

Callers 4

scheduleExpiryCheckFunction · 0.85
initFunction · 0.85
handleResumeFunction · 0.85
watchOfferFunction · 0.85

Calls 4

normalizeStatusFunction · 0.85
emitChangeFunction · 0.85
scheduleExpiryCheckFunction · 0.85
notifyFunction · 0.70

Tested by

no test coverage detected