()
| 243 | // previous load, else the defaults. A freshly fetched config is cached for |
| 244 | // the next load instead of swapping art and timing mid-session. |
| 245 | export const getPatchyConfig = (): PatchyConfig => { |
| 246 | if (typeof window === 'undefined') { |
| 247 | return defaultPatchyConfig; |
| 248 | } |
| 249 | if (!loadedConfig) { |
| 250 | let cached: Partial<PatchyConfigResponse> | null = null; |
| 251 | try { |
| 252 | cached = JSON.parse( |
| 253 | storageWrapper.getItem(PATCHY_CONFIG_STORAGE_KEY) ?? 'null', |
| 254 | ); |
| 255 | } catch { |
| 256 | cached = null; |
| 257 | } |
| 258 | loadedConfig = toPatchyConfig(cached); |
| 259 | } |
| 260 | return loadedConfig; |
| 261 | }; |
no test coverage detected