(status)
| 102 | } |
| 103 | |
| 104 | function normalizeStatus(status) { |
| 105 | const fallback = getDefaultState(); |
| 106 | if (!status || typeof status !== "object") return fallback; |
| 107 | |
| 108 | const adFreeUntil = Number(status.adFreeUntil) || 0; |
| 109 | const remainingMs = Math.max(0, Number(status.remainingMs) || 0); |
| 110 | |
| 111 | return { |
| 112 | ...fallback, |
| 113 | ...status, |
| 114 | adFreeUntil, |
| 115 | lastExpiredRewardUntil: Number(status.lastExpiredRewardUntil) || 0, |
| 116 | remainingMs, |
| 117 | redemptionsToday: Number(status.redemptionsToday) || 0, |
| 118 | remainingRedemptions: Number(status.remainingRedemptions) || 0, |
| 119 | maxRedemptionsPerDay: |
| 120 | Number(status.maxRedemptionsPerDay) || fallback.maxRedemptionsPerDay, |
| 121 | maxActivePassMs: Number(status.maxActivePassMs) || fallback.maxActivePassMs, |
| 122 | expiryNoticePendingUntil: Number(status.expiryNoticePendingUntil) || 0, |
| 123 | isActive: Boolean(status.isActive && adFreeUntil > Date.now()), |
| 124 | hasPendingExpiryNotice: Boolean(status.hasPendingExpiryNotice), |
| 125 | canRedeem: Boolean(status.canRedeem), |
| 126 | redeemDisabledReason: String(status.redeemDisabledReason || ""), |
| 127 | }; |
| 128 | } |
| 129 | |
| 130 | function clearExpiryTimer() { |
| 131 | if (expiryTimer) { |
no test coverage detected