|
7 | 7 | } from "@t3tools/contracts"; |
8 | 8 | import * as Option from "effect/Option"; |
9 | 9 | import * as Schema from "effect/Schema"; |
10 | | -import { useEffect, useMemo, useState } from "react"; |
| 10 | +import { useEffect, useState } from "react"; |
11 | 11 |
|
12 | 12 | import { isDesktopLocalConnectionTarget } from "~/connection/desktopLocal"; |
13 | 13 | import { isLoopbackHostname } from "~/environments/primary/target"; |
@@ -82,28 +82,27 @@ export function resolveRemoteOpenState(input: { |
82 | 82 |
|
83 | 83 | export function useRemoteOpenResolution(environmentId: EnvironmentId | null): RemoteOpenResolution { |
84 | 84 | const { presentation } = useEnvironmentPresentation(environmentId); |
85 | | - // The presentation changes with every server config push. Memoize on the |
86 | | - // pieces read here so callers keep a stable result across provider updates. |
| 85 | + // The presentation changes with every server config push. Read only the pieces |
| 86 | + // used here so the compiler keys the result on them and callers keep a stable |
| 87 | + // result across provider updates. |
87 | 88 | const entry = presentation?.entry ?? null; |
88 | 89 | const remoteOpenTargets = presentation?.serverConfig?.remoteOpenTargets; |
89 | 90 |
|
90 | | - return useMemo(() => { |
91 | | - if (entry === null) { |
92 | | - return UNRESOLVED_REMOTE_OPEN; |
93 | | - } |
94 | | - const profile = Option.getOrNull(entry.profile); |
95 | | - const sshAlias = |
96 | | - profile !== null && profile._tag === "SshConnectionProfile" ? profile.target.alias : null; |
97 | | - return { |
98 | | - state: resolveRemoteOpenState({ |
99 | | - target: entry.target, |
100 | | - sshAlias, |
101 | | - remoteOpenTargets, |
102 | | - isDesktopRenderer: window.desktopBridge !== undefined, |
103 | | - }), |
104 | | - isResolved: true, |
105 | | - }; |
106 | | - }, [entry, remoteOpenTargets]); |
| 91 | + if (entry === null) { |
| 92 | + return UNRESOLVED_REMOTE_OPEN; |
| 93 | + } |
| 94 | + const profile = Option.getOrNull(entry.profile); |
| 95 | + const sshAlias = |
| 96 | + profile !== null && profile._tag === "SshConnectionProfile" ? profile.target.alias : null; |
| 97 | + return { |
| 98 | + state: resolveRemoteOpenState({ |
| 99 | + target: entry.target, |
| 100 | + sshAlias, |
| 101 | + remoteOpenTargets, |
| 102 | + isDesktopRenderer: window.desktopBridge !== undefined, |
| 103 | + }), |
| 104 | + isResolved: true, |
| 105 | + }; |
107 | 106 | } |
108 | 107 |
|
109 | 108 | export function useRemoteOpenState(environmentId: EnvironmentId | null): RemoteOpenState { |
|
0 commit comments