From c514c5fb73f5af4f2920d4042c844eef8a3b748d Mon Sep 17 00:00:00 2001 From: Antigravity Date: Sun, 12 Apr 2026 18:15:04 +0100 Subject: [PATCH] Fix Lobby tab switching and message submission logic --- index.html | 2 +- static/chat.js | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 39b1d15..69e80a5 100644 --- a/index.html +++ b/index.html @@ -104,7 +104,7 @@
-
diff --git a/static/chat.js b/static/chat.js index f321cc1..ca81338 100644 --- a/static/chat.js +++ b/static/chat.js @@ -349,16 +349,20 @@ messageForm.addEventListener("submit", async (e) => { const isVioletRoom = state.currentRoom.toLowerCase().endsWith(":violet"); if (isVioletRoom) { - // AI Transit Encryption PM Flow - const transitKeyB64 = await SexyChato.exportKeyBase64(state.cryptoKey); - const encrypted = await SexyChato.encrypt(state.cryptoKey, text); - - socket.emit("pm_message", { - room: state.currentRoom, - ciphertext: encrypted.ciphertext, - nonce: encrypted.nonce, - transit_key: transitKeyB64 - }); + if (!state.isRegistered || !state.cryptoKey) { + addMessage(state.currentRoom, { system: true, text: "You must be logged in to chat with Violet." }); + } else { + // AI Transit Encryption PM Flow + const transitKeyB64 = await SexyChato.exportKeyBase64(state.cryptoKey); + const encrypted = await SexyChato.encrypt(state.cryptoKey, text); + + socket.emit("pm_message", { + room: state.currentRoom, + ciphertext: encrypted.ciphertext, + nonce: encrypted.nonce, + transit_key: transitKeyB64 + }); + } } else if (state.isRegistered && state.cryptoKey) { // E2E PM Flow const encrypted = await SexyChato.encrypt(state.cryptoKey, text);