@@ -5,7 +5,7 @@ import type {
55 DeviceSummary ,
66 EnvironmentId ,
77} from "@t3tools/contracts" ;
8- import { useEffect , useMemo , useRef , useState } from "react" ;
8+ import { useEffect , useRef , useState } from "react" ;
99import { deviceEnvironment } from "~/state/device" ;
1010import { formatEnvironmentQueryError } from "~/state/query" ;
1111import { useAtomCommand } from "~/state/use-atom-command" ;
@@ -36,15 +36,12 @@ export function useDeviceControls(options: {
3636 const busy = useRef ( false ) ;
3737 const generation = useRef ( 0 ) ;
3838 const visibleRead = useRef < Parameters < typeof readDetail > [ 0 ] | null > ( null ) ;
39- const target = useMemo (
40- ( ) => ( { hostId : device . hostId , deviceId : device . id } ) ,
41- [ device . hostId , device . id ] ,
42- ) ;
39+ const { hostId, id : deviceId } = device ;
4340
4441 useEffect ( ( ) => {
4542 const revision = ++ generation . current ;
4643 if ( ! visible ) return ;
47- const request = { environmentId, input : target } ;
44+ const request = { environmentId, input : { hostId , deviceId } } ;
4845 visibleRead . current = request ;
4946 void readDetail ( request ) . then ( ( result ) => {
5047 if ( generation . current !== revision ) return ;
@@ -60,7 +57,7 @@ export function useDeviceControls(options: {
6057 visibleRead . current = null ;
6158 generation . current ++ ;
6259 } ;
63- } , [ environmentId , readDetail , target , visible ] ) ;
60+ } , [ deviceId , environmentId , hostId , readDetail , visible ] ) ;
6461
6562 useEffect ( ( ) => {
6663 if ( ! access || ! visible ) return ;
@@ -87,7 +84,7 @@ export function useDeviceControls(options: {
8784 setError ( null ) ;
8885 return runAction ( {
8986 environmentId,
90- input : { ... target , ...body } as DeviceActionInput ,
87+ input : { hostId , deviceId , ...body } as DeviceActionInput ,
9188 } )
9289 . then ( ( result ) => {
9390 if ( generation . current !== revision ) {
0 commit comments