11import { PROVIDER_DISPLAY_NAMES } from "@t3tools/contracts" ;
2- import { useMemo , useRef , useState } from "react" ;
2+ import { settlePromise } from "@t3tools/client-runtime/state/runtime" ;
3+ import { useRef , useState } from "react" ;
34
45import { useEnvironments } from "~/state/environments" ;
56import { serverEnvironment } from "~/state/server" ;
@@ -19,22 +20,18 @@ export function useProviderUpdates() {
1920 const updateProvider = useAtomCommand ( serverEnvironment . updateProvider , {
2021 reportFailure : false ,
2122 } ) ;
22- const machines = useMemo (
23- ( ) =>
24- environments . flatMap ( ( environment ) => {
25- const providers = environment . serverConfig ?. providers ?? [ ] ;
26- if ( environment . connection . phase !== "connected" ) {
27- return [ ] ;
28- }
29- const candidates = collectProviderUpdateCandidates ( providers ) . filter ( ( candidate ) =>
30- canOneClickUpdateProviderCandidate ( candidate , providers ) ,
31- ) ;
32- return candidates . length > 0
33- ? [ { environmentId : environment . environmentId , label : environment . label , candidates } ]
34- : [ ] ;
35- } ) ,
36- [ environments ] ,
37- ) ;
23+ const machines = environments . flatMap ( ( environment ) => {
24+ const providers = environment . serverConfig ?. providers ?? [ ] ;
25+ if ( environment . connection . phase !== "connected" ) {
26+ return [ ] ;
27+ }
28+ const candidates = collectProviderUpdateCandidates ( providers ) . filter ( ( candidate ) =>
29+ canOneClickUpdateProviderCandidate ( candidate , providers ) ,
30+ ) ;
31+ return candidates . length > 0
32+ ? [ { environmentId : environment . environmentId , label : environment . label , candidates } ]
33+ : [ ] ;
34+ } ) ;
3835
3936 const updateAll = async ( { quiet = false } : { readonly quiet ?: boolean } = { } ) => {
4037 const runs = await Promise . all (
@@ -78,12 +75,9 @@ export function ProviderUpdatesAction() {
7875 if ( pending . current ) return ;
7976 pending . current = true ;
8077 setIsPending ( true ) ;
81- try {
82- await updateAll ( ) ;
83- } finally {
84- pending . current = false ;
85- setIsPending ( false ) ;
86- }
78+ await settlePromise ( ( ) => updateAll ( ) ) ;
79+ pending . current = false ;
80+ setIsPending ( false ) ;
8781 } ;
8882
8983 return (
0 commit comments