Skip to content

Commit eb5588c

Browse files
committed
fix: resolve API validation and WebSocket message issues
1 parent be5cad2 commit eb5588c

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/lib/api/api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ class ClerkEncryptedApiService {
256256
method: 'POST',
257257
body: JSON.stringify({
258258
...restNoteData,
259+
// Temporary placeholder until API is updated to make title optional
260+
title: "temp",
259261
...encryptedData,
260262
}),
261263
});
@@ -285,11 +287,9 @@ class ClerkEncryptedApiService {
285287

286288
const encrypted = await this.encryptNoteForApi(newTitle, newContent);
287289

290+
const { title: _, content: __, ...restUpdates } = updates;
288291
encryptedUpdates = {
289-
...updates,
290-
// Remove plain text fields completely when sending encrypted data
291-
title: undefined,
292-
content: undefined,
292+
...restUpdates,
293293
...encrypted,
294294
};
295295
}

src/services/webSocketService.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ class WebSocketService implements WebSocketServiceInterface {
228228
return;
229229
}
230230

231+
if (!noteId || typeof noteId !== 'string') {
232+
return;
233+
}
234+
231235
if (this.state.joinedNotes.has(noteId)) {
232236
return;
233237
}
@@ -240,6 +244,10 @@ class WebSocketService implements WebSocketServiceInterface {
240244
return;
241245
}
242246

247+
if (!noteId || typeof noteId !== 'string') {
248+
return;
249+
}
250+
243251
if (!this.state.joinedNotes.has(noteId)) {
244252
return;
245253
}
@@ -252,6 +260,10 @@ class WebSocketService implements WebSocketServiceInterface {
252260
return;
253261
}
254262

263+
if (!noteId || typeof noteId !== 'string') {
264+
return;
265+
}
266+
255267
this.sendMessage({
256268
type: 'note_update',
257269
noteId,
@@ -276,6 +288,7 @@ class WebSocketService implements WebSocketServiceInterface {
276288

277289
this.sendMessage({
278290
type: 'note_created',
291+
noteId: note.id,
279292
noteData: note,
280293
});
281294
}

0 commit comments

Comments
 (0)