(
kind: SimulatorTransition["kind"],
udid: string,
action: () => Promise<SimulatorMetadata | null>,
)
| 2182 | } |
| 2183 | |
| 2184 | async function runSimulatorLifecycleAction( |
| 2185 | kind: SimulatorTransition["kind"], |
| 2186 | udid: string, |
| 2187 | action: () => Promise<SimulatorMetadata | null>, |
| 2188 | ) { |
| 2189 | setSimulatorTransition({ kind, udid }); |
| 2190 | setLocalError(""); |
| 2191 | try { |
| 2192 | const simulator = await action(); |
| 2193 | if (simulator) { |
| 2194 | updateSimulator(simulator); |
| 2195 | setSelectedSimulatorState((current) => |
| 2196 | current?.udid === simulator.udid || |
| 2197 | baseSelectedSimulator?.udid === simulator.udid |
| 2198 | ? selectedStateFromSimulator(simulator, current) |
| 2199 | : current, |
| 2200 | ); |
| 2201 | } |
| 2202 | setSimulatorTransition((current) => |
| 2203 | current?.udid === udid && current.kind === kind ? null : current, |
| 2204 | ); |
| 2205 | void refresh(); |
| 2206 | } catch (actionError) { |
| 2207 | setLocalError( |
| 2208 | actionError instanceof Error ? actionError.message : "Request failed.", |
| 2209 | ); |
| 2210 | setSimulatorTransition((current) => |
| 2211 | current?.udid === udid && current.kind === kind ? null : current, |
| 2212 | ); |
| 2213 | } |
| 2214 | } |
| 2215 | |
| 2216 | const closeControlSocket = useCallback(() => { |
| 2217 | const current = controlSocketRef.current; |
no test coverage detected