@@ -22,30 +22,26 @@ export function useHostConnectionChecks(targets: ReadonlyArray<DeviceHostCheckTa
2222 running . current . add ( key ) ;
2323 setChecks ( ( current ) => ( { ...current , [ key ] : { } } ) ) ;
2424 const results : Record < string , DeviceHostCheck > = { } ;
25- try {
26- await checkDeviceHostConnections (
27- targets ,
28- host ,
29- async ( environmentId , input ) => {
30- if ( ! readEnvironmentScope ( environmentId , AuthSettingsWriteScope ) ) {
31- throw new Error ( "This connection cannot test device hosts." ) ;
32- }
33- const result = await test ( { environmentId, input } ) ;
34- if ( result . _tag === "Failure" ) throw new Error ( Cause . pretty ( result . cause ) ) ;
35- return result . value ;
36- } ,
37- ( environmentId , result ) => {
38- results [ environmentId ] = result ;
39- setChecks ( ( current ) => ( {
40- ...current ,
41- [ key ] : { ...current [ key ] , [ environmentId ] : result } ,
42- } ) ) ;
43- } ,
44- ) ;
45- return results ;
46- } finally {
47- running . current . delete ( key ) ;
48- }
25+ await checkDeviceHostConnections (
26+ targets ,
27+ host ,
28+ async ( environmentId , input ) => {
29+ if ( ! readEnvironmentScope ( environmentId , AuthSettingsWriteScope ) ) {
30+ throw new Error ( "This connection cannot test device hosts." ) ;
31+ }
32+ const result = await test ( { environmentId, input } ) ;
33+ if ( result . _tag === "Failure" ) throw new Error ( Cause . pretty ( result . cause ) ) ;
34+ return result . value ;
35+ } ,
36+ ( environmentId , result ) => {
37+ results [ environmentId ] = result ;
38+ setChecks ( ( current ) => ( {
39+ ...current ,
40+ [ key ] : { ...current [ key ] , [ environmentId ] : result } ,
41+ } ) ) ;
42+ } ,
43+ ) . finally ( ( ) => running . current . delete ( key ) ) ;
44+ return results ;
4945 } ;
5046 return { checks, testConnection } ;
5147}
0 commit comments