()
| 279 | // previous load, else the defaults. A freshly fetched config is cached for |
| 280 | // the next load instead of swapping art and timing mid-session. |
| 281 | export const getPatchyConfig = (): PatchyConfig => { |
| 282 | if (typeof window === 'undefined') { |
| 283 | return defaultPatchyConfig; |
| 284 | } |
| 285 | if (!loadedConfig) { |
| 286 | let cached: Partial<PatchyConfigResponse> | null = null; |
| 287 | try { |
| 288 | cached = JSON.parse( |
| 289 | storageWrapper.getItem(PATCHY_CONFIG_STORAGE_KEY) ?? 'null', |
| 290 | ); |
| 291 | } catch { |
| 292 | cached = null; |
| 293 | } |
| 294 | loadedConfig = toPatchyConfig(cached); |
| 295 | } |
| 296 | return loadedConfig; |
| 297 | }; |
| 298 | |
| 299 | // Whether a face animates is read off the image the config gives it, so a |
| 300 | // config that points a face back at a still image gets the circle's motion |
no test coverage detected