From 5839374fda16b50b9c3831d931687e95eb77e4a6 Mon Sep 17 00:00:00 2001 From: ynwd <10122431+ynwd@users.noreply.github.com> Date: Fri, 29 Nov 2024 16:26:09 +0700 Subject: [PATCH] chore: update socket --- deno.json | 2 +- modules/hook/socket.ts | 3 +-- modules/index/index.room.tsx | 12 ++---------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/deno.json b/deno.json index a9c7829e..afdedf07 100644 --- a/deno.json +++ b/deno.json @@ -22,7 +22,7 @@ }, "nodeModulesDir": "auto", "tasks": { - "start": "ENV=DEVELOPMENT deno run -r --env --unstable-kv -A --watch modules/app/main.ts --debug", + "start": "ENV=DEVELOPMENT deno run --env --unstable-kv -A --watch modules/app/main.ts --debug", "build": "deno run --env -A --unstable-kv modules/app/main.ts --build ", "prod": "deno run --env --unstable-kv -A modules/app/main.ts", "test": "rm -rf .hydrate && rm -rf cov && deno test --env --unstable-kv -A --coverage=cov && deno coverage cov", diff --git a/modules/hook/socket.ts b/modules/hook/socket.ts index 2d9c4e94..73956d19 100644 --- a/modules/hook/socket.ts +++ b/modules/hook/socket.ts @@ -25,8 +25,7 @@ const useWebSocket = (url: string, room: string, user: string) => { ...data, }), ); - countRef.current++; - return console.log(`WebSocket connection established: ${room}`); + return countRef.current++; } console.log(`WebSocket connection closed: ${room}`); diff --git a/modules/index/index.room.tsx b/modules/index/index.room.tsx index 7961a5ee..f1993493 100644 --- a/modules/index/index.room.tsx +++ b/modules/index/index.room.tsx @@ -12,9 +12,7 @@ export function Room( const state = useContext(AppContext); const { data } = useFetch(`/api/room/${props.id}`); - const handleChange = ( - e: JSX.TargetedEvent, - ) => { + const handleChange = (e: JSX.TargetedEvent) => { const target = e.target as HTMLInputElement; setSelected(target.value); state.room.value = data as { @@ -33,13 +31,7 @@ export function Room( name="room" type="radio" value={props.id} - onInput={(e) => - handleChange( - e as JSX.TargetedEvent< - HTMLInputElement, - InputEvent - >, - )} + onChange={handleChange} checked={selected === props.id} disabled={props.disabled} class="w-4 h-4 text-blue-600 bg-gray-100 focus:ring-blue-600 ring-offset-gray-700 focus:ring-offset-gray-700 focus:ring-2 border-gray-500"