@@ -105,10 +105,8 @@ wss.on("connection", (socket, req) => __awaiter(void 0, void 0, void 0, function
105105 userId : client_1 . chatsTable . userId ,
106106 roomId : client_1 . chatsTable . roomId ,
107107 } ) ;
108- // Need to fetch user details separately or join?
109- // Returning clause only returns table columns.
110- // To match previous Select behavior (including user relation), we might need a subsequent fetch or just return what we have if the client handles it.
111- // But let's fetch user name if needed by client.
108+ if ( ! addChat )
109+ throw new Error ( "Failed to insert chat message" ) ;
112110 const user = yield client_1 . db . select ( { username : client_1 . usersTable . username } ) . from ( client_1 . usersTable ) . where ( ( 0 , drizzle_orm_1 . eq ) ( client_1 . usersTable . id , addChat . userId ) ) ;
113111 const chatWithUser = Object . assign ( Object . assign ( { } , addChat ) , { user : {
114112 username : ( _b = user [ 0 ] ) === null || _b === void 0 ? void 0 : _b . username
@@ -142,7 +140,6 @@ wss.on("connection", (socket, req) => __awaiter(void 0, void 0, void 0, function
142140 }
143141 const drawData = JSON . parse ( validMessage . data . content ) ;
144142 try {
145- let addedDraw ;
146143 let draw ;
147144 switch ( drawData . type ) {
148145 case "create" :
@@ -152,13 +149,13 @@ wss.on("connection", (socket, req) => __awaiter(void 0, void 0, void 0, function
152149 shape : draw . shape ,
153150 strokeStyle : draw . strokeStyle ,
154151 fillStyle : draw . fillStyle ,
155- lineWidth : draw . lineWidth ,
152+ lineWidth : Math . round ( draw . lineWidth ) ,
156153 font : draw . font ,
157154 fontSize : draw . fontSize ,
158- startX : draw . startX ,
159- startY : draw . startY ,
160- endX : draw . endX ,
161- endY : draw . endY ,
155+ startX : draw . startX ? Math . round ( draw . startX ) : null ,
156+ startY : draw . startY ? Math . round ( draw . startY ) : null ,
157+ endX : draw . endX ? Math . round ( draw . endX ) : null ,
158+ endY : draw . endY ? Math . round ( draw . endY ) : null ,
162159 text : draw . text ,
163160 points : draw . points ,
164161 roomId : validMessage . data . roomId ,
@@ -169,16 +166,16 @@ wss.on("connection", (socket, req) => __awaiter(void 0, void 0, void 0, function
169166 case "resize" :
170167 draw = drawData . modifiedDraw ;
171168 yield client_1 . db . update ( client_1 . drawsTable ) . set ( {
172- startX : draw . startX ,
173- startY : draw . startY ,
174- endX : draw . endX ,
175- endY : draw . endY ,
169+ startX : draw . startX ? Math . round ( draw . startX ) : null ,
170+ startY : draw . startY ? Math . round ( draw . startY ) : null ,
171+ endX : draw . endX ? Math . round ( draw . endX ) : null ,
172+ endY : draw . endY ? Math . round ( draw . endY ) : null ,
176173 text : draw . text ,
177174 points : draw . points ,
178175 shape : draw . shape ,
179176 strokeStyle : draw . strokeStyle ,
180177 fillStyle : draw . fillStyle ,
181- lineWidth : draw . lineWidth ,
178+ lineWidth : Math . round ( draw . lineWidth ) ,
182179 font : draw . font ,
183180 fontSize : draw . fontSize ,
184181 } ) . where ( ( 0 , drizzle_orm_1 . eq ) ( client_1 . drawsTable . id , draw . id ) ) ;
0 commit comments