From 8fd3063420ea9941677015e31dd9deb4eb36556e Mon Sep 17 00:00:00 2001 From: NigeParis Date: Sat, 29 Nov 2025 17:47:04 +0100 Subject: [PATCH] Bug - db fixed --- frontend/src/pages/chat/chat.ts | 30 ++++++------------------------ src/@shared/src/database/init.sql | 4 ++-- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index a0c3faf..8dfeefc 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -10,7 +10,7 @@ const color = { green: 'color: green; font-weight: bold;', yellow: 'color: orange; font-weight: bold;', blue: 'color: blue; font-weight: bold;', - reset: '', // not needed in browser + reset: '', }; @@ -27,8 +27,8 @@ document.addEventListener('ft:pageChange', () => { }) function getSocket(): Socket { - let addressHost = `wss://${machineHostName}:8888`; - // let addressHost = `wss://localhost:8888`; + // let addressHost = `wss://${machineHostName}:8888`; + let addressHost = `wss://localhost:8888`; if (__socket === undefined) __socket = io(addressHost, { @@ -144,14 +144,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn if (chatWindow) { const messageElement = document.createElement("div"); - - // if (getUser()?.id !== `${data.message.id}`) { - console.log('==================> HERE'); messageElement.textContent = `${data.message.user}: ${data.message.text}`; - // } else { - // console.log('==================>AND HERE'); - // messageElement.textContent = `here`; - // } chatWindow.appendChild(messageElement); chatWindow.scrollTop = chatWindow.scrollHeight; } @@ -178,20 +171,13 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn }); window.addEventListener("blur", () => { - // if (window.location.pathname !== "/app/chat" && !toggle) { - // // bconnected.click(); - // console.log("%cWindow is not focused on /chat", color.red); - + bconnected.click(); + console.log("%cWindow is not focused on /chat", color.red); if (socket.id) windowStateHidden(); - // }); - toggle = false; - // } + toggle = false; }); - - - setTitle('Chat Page'); // Listen for the 'connect' event return { @@ -299,9 +285,6 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn }); - - - // Enter key to send message sendtextbox!.addEventListener('keydown', (event) => { if (event.key === 'Enter') { @@ -346,5 +329,4 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn } }; addRoute('/chat', handleChat, { bypass_auth: true }); -// addRoute('/chat/', handleChat, { bypass_auth: true }); diff --git a/src/@shared/src/database/init.sql b/src/@shared/src/database/init.sql index b4e1415..b77edfe 100644 --- a/src/@shared/src/database/init.sql +++ b/src/@shared/src/database/init.sql @@ -14,8 +14,8 @@ CREATE TABLE IF NOT EXISTS blocked ( user TEXT NOT NULL, blocked TEXT NOT NULL, - FOREIGN KEY(user) REFERENCES user(id); - FOREIGN KEY(blocked) REFERENCES user(id); + FOREIGN KEY(user) REFERENCES user(id) + FOREIGN KEY(blocked) REFERENCES user(id) ); CREATE UNIQUE INDEX IF NOT EXISTS idx_blocked_user_pair