Skip to content

Commit a3ba485

Browse files
committed
fix: bugfix
1 parent 7d48e43 commit a3ba485

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/pages/Policies/components/PolicyGroup.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,25 @@ const PolicyGroup: React.FC<PolicyGroupProps> = ({
102102
} = {}
103103

104104
if (policyPerformanceResults) {
105-
mutatePolicyPerformanceResults()
106-
return
105+
return Promise.all([
106+
refreshSelection().then((policy) => {
107+
setSelection(policy)
108+
}),
109+
mutatePolicyPerformanceResults(),
110+
])
107111
}
108112

109113
if (res.winner) {
110114
const testResult = (res as UrlTestPolicyTestResult).results[0].data
115+
111116
Object.keys(testResult).forEach((key) => {
112117
const result = testResult[key]
113118

114119
latencies[key] = result.receive
115120
? Number(result.receive.toFixed(0))
116121
: -1
117122
})
123+
118124
setSelection((res as UrlTestPolicyTestResult).winner)
119125
} else {
120126
const testResult = res as SelectPolicyTestResult

src/pages/Policies/usePolicyPerformance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import useSWR, { mutate } from 'swr'
2-
import { useVersionSupport } from '../../hooks'
32

3+
import { useVersionSupport } from '../../hooks'
44
import { PolicyBenchmarkResults } from '../../types'
55
import fetcher from '../../utils/fetcher'
66

@@ -9,7 +9,7 @@ export const mutatePolicyPerformanceResults = () =>
99

1010
export const usePolicyPerformance = () => {
1111
const isSupported = useVersionSupport({
12-
ios: '0.0.0',
12+
ios: '4.9.5',
1313
macos: '4.2.4',
1414
})
1515
const { data, error } = useSWR<PolicyBenchmarkResults>(

src/serviceWorkerRegistration.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,11 @@ export function unregister() {
144144
})
145145
}
146146
}
147+
148+
export async function unregisterAsync() {
149+
if ('serviceWorker' in navigator) {
150+
return navigator.serviceWorker.ready.then((registration) => {
151+
return registration.unregister()
152+
})
153+
}
154+
}

0 commit comments

Comments
 (0)