Skip to content

Commit 5a0ff7b

Browse files
committed
Fix decimal coord error
1 parent de2d557 commit 5a0ff7b

File tree

7 files changed

+434
-26
lines changed

7 files changed

+434
-26
lines changed

apps/web/tsconfig.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
"compilerOptions": {
44
"baseUrl": ".",
55
"paths": {
6-
"@/*": ["./*"],
7-
"@workspace/ui/*": ["../../packages/ui/src/*"]
6+
"@/*": [
7+
"./*"
8+
],
9+
"@workspace/ui/*": [
10+
"../../packages/ui/src/*"
11+
]
812
},
913
"plugins": [
1014
{
1115
"name": "next"
1216
}
1317
],
14-
"jsx": "react-jsx"
18+
"jsx": "preserve"
1519
},
1620
"include": [
1721
"next-env.d.ts",
@@ -20,5 +24,7 @@
2024
"**/*.tsx",
2125
".next/types/**/*.ts"
2226
],
23-
"exclude": ["node_modules"]
27+
"exclude": [
28+
"node_modules"
29+
]
2430
}

apps/ws-server/dist/index.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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));

apps/ws-server/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ wss.on("connection", async (socket: WebSocket, req: Request) => {
179179
const drawData = JSON.parse(validMessage.data.content!);
180180

181181
try {
182-
let addedDraw;
183182
let draw;
184183
switch (drawData.type) {
185184
case "create":
@@ -332,7 +331,6 @@ wss.on("connection", async (socket: WebSocket, req: Request) => {
332331
process.env.JWT_SECRET || "kjhytfrde45678iuytrfdcfgy6tr"
333332
) as JwtPayload;
334333

335-
// Prevent DrizzleQueryError: valid UUID check
336334
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
337335
if (!uuidRegex.test(verified.id)) {
338336
console.log("Invalid User ID format");
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ALTER TABLE "draw" ALTER COLUMN "lineWidth" SET DATA TYPE real;--> statement-breakpoint
2+
ALTER TABLE "draw" ALTER COLUMN "startX" SET DATA TYPE real;--> statement-breakpoint
3+
ALTER TABLE "draw" ALTER COLUMN "startY" SET DATA TYPE real;--> statement-breakpoint
4+
ALTER TABLE "draw" ALTER COLUMN "endX" SET DATA TYPE real;--> statement-breakpoint
5+
ALTER TABLE "draw" ALTER COLUMN "endY" SET DATA TYPE real;

0 commit comments

Comments
 (0)