Skip to content

Commit efb3bf6

Browse files
committed
Remove latency pulled from storage
1 parent f4f6291 commit efb3bf6

File tree

1 file changed

+3
-27
lines changed

1 file changed

+3
-27
lines changed

site/src/contexts/useProxyLatency.ts

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,8 @@ const proxyLatenciesReducer = (
2424
state: Record<string, ProxyLatencyReport>,
2525
action: ProxyLatencyAction,
2626
): Record<string, ProxyLatencyReport> => {
27-
// TODO: We should probably not read from local storage on every action.
28-
const history = loadStoredLatencies()
29-
const proxyHistory = history[action.proxyID] || []
30-
const minReport = proxyHistory.reduce((min, report) => {
31-
if (min.latencyMS === 0) {
32-
// Not yet set, so use the new report.
33-
return report
34-
}
35-
if (min.latencyMS < report.latencyMS) {
36-
return min
37-
}
38-
return report
39-
}, {} as ProxyLatencyReport)
40-
41-
if (
42-
minReport.latencyMS > 0 &&
43-
minReport.latencyMS < action.report.latencyMS
44-
) {
45-
// The new report is slower then the min report, so use the min report.
46-
return {
47-
...state,
48-
[action.proxyID]: minReport,
49-
}
50-
}
51-
52-
// Use the new report
27+
// Always return the new report. We have some saved latencies, but until we have a better
28+
// way to utilize them, we will ignore them for all practical purposes.
5329
return {
5430
...state,
5531
[action.proxyID]: action.report,
@@ -65,7 +41,7 @@ export const useProxyLatency = (
6541
proxyLatencies: Record<string, ProxyLatencyReport>
6642
} => {
6743
// maxStoredLatencies is the maximum number of latencies to store per proxy in local storage.
68-
let maxStoredLatencies = 8
44+
let maxStoredLatencies = 1
6945
// The reason we pull this from local storage is so for development purposes, a user can manually
7046
// set a larger number to collect data in their normal usage. This data can later be analyzed to come up
7147
// with some better magic numbers.

0 commit comments

Comments
 (0)