From 5257bbfd4ff7887bb81032bc8730deab9cbb96bd Mon Sep 17 00:00:00 2001 From: Deveshi Dwivedi Date: Sat, 22 Jun 2024 12:12:11 +0530 Subject: [PATCH] add ClientRoom interface --- common/recoil/room/room.atom.ts | 2 +- common/recoil/room/room.hooks.ts | 4 ++-- common/types/global.d.ts | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/common/recoil/room/room.atom.ts b/common/recoil/room/room.atom.ts index f3570a7..f378364 100644 --- a/common/recoil/room/room.atom.ts +++ b/common/recoil/room/room.atom.ts @@ -1,6 +1,6 @@ import { atom } from "recoil"; -export const roomAtom = atom({ +export const roomAtom = atom({ key: "room", default: { id: "", diff --git a/common/recoil/room/room.hooks.ts b/common/recoil/room/room.hooks.ts index 44f9005..cf545c0 100644 --- a/common/recoil/room/room.hooks.ts +++ b/common/recoil/room/room.hooks.ts @@ -11,7 +11,7 @@ export const useSetRoomId = () => { const setRoomId= useSetRecoilState(roomAtom); const handleSetRoomId = (id: string) => { - setRoomId({id}); + setRoomId((prev)=> ({...prev,id})); }; - return handleSetRoomId + return handleSetRoomId; }; \ No newline at end of file diff --git a/common/types/global.d.ts b/common/types/global.d.ts index f3ad383..3b09407 100644 --- a/common/types/global.d.ts +++ b/common/types/global.d.ts @@ -11,6 +11,13 @@ export declare global { type Room = {users: Map; drawed: Move[]}; + interface ClientRoom{ + id:string; + users: Map; + movesWithoutUser: Move[]; + myMoves: Move[]; + } + interface ServerToClientEvents { room: (room: Room, usersToParse: string)=> void; created: (roomId: string) => void;