(value: unknown)
| 221 | } |
| 222 | |
| 223 | function sanitizeDonations(value: unknown): DonationsState { |
| 224 | const source = asRecord(value) |
| 225 | const copiesSource = asRecord(source.copies) |
| 226 | const createdSource = asRecord(source.created) |
| 227 | const sentSource = asRecord(source.sent) |
| 228 | const copyMilestonesSource = asRecord(source.lastShownCopyMilestones) |
| 229 | const createdMilestonesSource = asRecord(source.lastShownCreatedMilestones) |
| 230 | const sentMilestonesSource = asRecord(source.lastShownSentMilestones) |
| 231 | const defaults = APP_STORE_DEFAULTS.donations |
| 232 | const shownStreaks = readOptionalNumberArray(source, 'shownStreakMilestones') |
| 233 | |
| 234 | return { |
| 235 | lastActiveDay: readString(source, 'lastActiveDay', defaults.lastActiveDay), |
| 236 | currentStreak: readNumber(source, 'currentStreak', defaults.currentStreak), |
| 237 | copies: { |
| 238 | code: readNumber(copiesSource, 'code', defaults.copies.code), |
| 239 | http: readNumber(copiesSource, 'http', defaults.copies.http), |
| 240 | notes: readNumber(copiesSource, 'notes', defaults.copies.notes), |
| 241 | math: readNumber(copiesSource, 'math', defaults.copies.math), |
| 242 | tools: readNumber(copiesSource, 'tools', defaults.copies.tools), |
| 243 | drawings: readNumber(copiesSource, 'drawings', defaults.copies.drawings), |
| 244 | }, |
| 245 | created: { |
| 246 | code: readNumber(createdSource, 'code', defaults.created.code), |
| 247 | http: readNumber(createdSource, 'http', defaults.created.http), |
| 248 | notes: readNumber(createdSource, 'notes', defaults.created.notes), |
| 249 | math: readNumber(createdSource, 'math', defaults.created.math), |
| 250 | drawings: readNumber( |
| 251 | createdSource, |
| 252 | 'drawings', |
| 253 | defaults.created.drawings, |
| 254 | ), |
| 255 | }, |
| 256 | sent: { |
| 257 | http: readNumber(sentSource, 'http', defaults.sent.http), |
| 258 | }, |
| 259 | lastShownCopyMilestones: { |
| 260 | code: readNumber( |
| 261 | copyMilestonesSource, |
| 262 | 'code', |
| 263 | defaults.lastShownCopyMilestones.code, |
| 264 | ), |
| 265 | http: readNumber( |
| 266 | copyMilestonesSource, |
| 267 | 'http', |
| 268 | defaults.lastShownCopyMilestones.http, |
| 269 | ), |
| 270 | notes: readNumber( |
| 271 | copyMilestonesSource, |
| 272 | 'notes', |
| 273 | defaults.lastShownCopyMilestones.notes, |
| 274 | ), |
| 275 | math: readNumber( |
| 276 | copyMilestonesSource, |
| 277 | 'math', |
| 278 | defaults.lastShownCopyMilestones.math, |
| 279 | ), |
| 280 | tools: readNumber( |
no test coverage detected