()
| 259 | // If a single request is slow, we want to omit that latency check, and go with |
| 260 | // a more accurate latency check. |
| 261 | const loadStoredLatencies = (): Record<string, ProxyLatencyReport[]> => { |
| 262 | const str = localStorage.getItem("workspace-proxy-latencies"); |
| 263 | if (!str) { |
| 264 | return {}; |
| 265 | } |
| 266 | |
| 267 | return JSON.parse(str, (key, value) => { |
| 268 | // By default json loads dates as strings. We want to convert them back to 'Date's. |
| 269 | if (key === "at") { |
| 270 | return new Date(value); |
| 271 | } |
| 272 | return value; |
| 273 | }); |
| 274 | }; |
| 275 | |
| 276 | const updateStoredLatencies = (action: ProxyLatencyAction): void => { |
| 277 | const latencies = loadStoredLatencies(); |
no test coverage detected