MCPcopy Create free account
hub / github.com/coder/coder / loadStoredLatencies

Function loadStoredLatencies

site/src/contexts/useProxyLatency.ts:261–274  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

259// If a single request is slow, we want to omit that latency check, and go with
260// a more accurate latency check.
261const 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
276const updateStoredLatencies = (action: ProxyLatencyAction): void => {
277 const latencies = loadStoredLatencies();

Callers 3

useProxyLatencyFunction · 0.85
updateStoredLatenciesFunction · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected