|
1 | 1 | import type { ConnectionCatalogEntry } from "@t3tools/client-runtime/connection"; |
2 | 2 | import type { ServerConfig } from "@t3tools/contracts"; |
3 | | -import { useMemo } from "react"; |
4 | 3 |
|
5 | 4 | import { useEnvironments, usePrimaryEnvironmentId } from "~/state/environments"; |
6 | 5 | import { isDesktopLocalConnectionTarget } from "~/connection/desktopLocal"; |
@@ -40,37 +39,33 @@ export function useLocalEnvironmentUpdateGroups(): { |
40 | 39 | const { environments } = useEnvironments(); |
41 | 40 | const primaryEnvironmentId = usePrimaryEnvironmentId(); |
42 | 41 |
|
43 | | - return useMemo(() => { |
44 | | - const inputs: LocalEnvironmentProvidersInput[] = []; |
| 42 | + const inputs: LocalEnvironmentProvidersInput[] = []; |
45 | 43 |
|
46 | | - for (const environment of environments) { |
47 | | - if (!isLocalConnectionTarget(environment.entry.target)) { |
48 | | - continue; |
49 | | - } |
| 44 | + for (const environment of environments) { |
| 45 | + if (!isLocalConnectionTarget(environment.entry.target)) { |
| 46 | + continue; |
| 47 | + } |
50 | 48 |
|
51 | | - const isPrimary = environment.environmentId === primaryEnvironmentId; |
52 | | - const serverConfig: ServerConfig | null = environment.serverConfig; |
| 49 | + const isPrimary = environment.environmentId === primaryEnvironmentId; |
| 50 | + const serverConfig: ServerConfig | null = environment.serverConfig; |
53 | 51 |
|
54 | | - inputs.push({ |
55 | | - environmentId: environment.environmentId, |
56 | | - label: isPrimary |
57 | | - ? deriveEnvironmentDisplayLabel({ |
58 | | - isWsl: false, |
59 | | - wslDistro: null, |
60 | | - platformOs: serverConfig?.environment.platform.os, |
61 | | - fallbackLabel: environment.label, |
62 | | - }) |
63 | | - : environment.label, |
64 | | - isPrimary, |
65 | | - connectionState: isPrimary |
66 | | - ? "ready" |
67 | | - : normalizeConnectionState(environment.connection.phase), |
68 | | - providers: serverConfig?.providers ?? [], |
69 | | - }); |
70 | | - } |
| 52 | + inputs.push({ |
| 53 | + environmentId: environment.environmentId, |
| 54 | + label: isPrimary |
| 55 | + ? deriveEnvironmentDisplayLabel({ |
| 56 | + isWsl: false, |
| 57 | + wslDistro: null, |
| 58 | + platformOs: serverConfig?.environment.platform.os, |
| 59 | + fallbackLabel: environment.label, |
| 60 | + }) |
| 61 | + : environment.label, |
| 62 | + isPrimary, |
| 63 | + connectionState: isPrimary ? "ready" : normalizeConnectionState(environment.connection.phase), |
| 64 | + providers: serverConfig?.providers ?? [], |
| 65 | + }); |
| 66 | + } |
71 | 67 |
|
72 | | - inputs.sort((left, right) => Number(right.isPrimary) - Number(left.isPrimary)); |
| 68 | + inputs.sort((left, right) => Number(right.isPrimary) - Number(left.isPrimary)); |
73 | 69 |
|
74 | | - return buildLocalEnvironmentUpdateGroups(inputs); |
75 | | - }, [environments, primaryEnvironmentId]); |
| 70 | + return buildLocalEnvironmentUpdateGroups(inputs); |
76 | 71 | } |
0 commit comments