File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -102,19 +102,25 @@ const PolicyGroup: React.FC<PolicyGroupProps> = ({
102
102
} = { }
103
103
104
104
if ( policyPerformanceResults ) {
105
- mutatePolicyPerformanceResults ( )
106
- return
105
+ return Promise . all ( [
106
+ refreshSelection ( ) . then ( ( policy ) => {
107
+ setSelection ( policy )
108
+ } ) ,
109
+ mutatePolicyPerformanceResults ( ) ,
110
+ ] )
107
111
}
108
112
109
113
if ( res . winner ) {
110
114
const testResult = ( res as UrlTestPolicyTestResult ) . results [ 0 ] . data
115
+
111
116
Object . keys ( testResult ) . forEach ( ( key ) => {
112
117
const result = testResult [ key ]
113
118
114
119
latencies [ key ] = result . receive
115
120
? Number ( result . receive . toFixed ( 0 ) )
116
121
: - 1
117
122
} )
123
+
118
124
setSelection ( ( res as UrlTestPolicyTestResult ) . winner )
119
125
} else {
120
126
const testResult = res as SelectPolicyTestResult
Original file line number Diff line number Diff line change 1
1
import useSWR , { mutate } from 'swr'
2
- import { useVersionSupport } from '../../hooks'
3
2
3
+ import { useVersionSupport } from '../../hooks'
4
4
import { PolicyBenchmarkResults } from '../../types'
5
5
import fetcher from '../../utils/fetcher'
6
6
@@ -9,7 +9,7 @@ export const mutatePolicyPerformanceResults = () =>
9
9
10
10
export const usePolicyPerformance = ( ) => {
11
11
const isSupported = useVersionSupport ( {
12
- ios : '0.0.0 ' ,
12
+ ios : '4.9.5 ' ,
13
13
macos : '4.2.4' ,
14
14
} )
15
15
const { data, error } = useSWR < PolicyBenchmarkResults > (
Original file line number Diff line number Diff line change @@ -144,3 +144,11 @@ export function unregister() {
144
144
} )
145
145
}
146
146
}
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
+ }
You can’t perform that action at this time.
0 commit comments