Bug - db fixed

This commit is contained in:
NigeParis 2025-11-29 17:47:04 +01:00 committed by apetitco
parent 270c3297fd
commit 8fd3063420
2 changed files with 8 additions and 26 deletions

View file

@ -10,7 +10,7 @@ const color = {
green: 'color: green; font-weight: bold;', green: 'color: green; font-weight: bold;',
yellow: 'color: orange; font-weight: bold;', yellow: 'color: orange; font-weight: bold;',
blue: 'color: blue; 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 { function getSocket(): Socket {
let addressHost = `wss://${machineHostName}:8888`; // let addressHost = `wss://${machineHostName}:8888`;
// let addressHost = `wss://localhost:8888`; let addressHost = `wss://localhost:8888`;
if (__socket === undefined) if (__socket === undefined)
__socket = io(addressHost, { __socket = io(addressHost, {
@ -144,14 +144,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn
if (chatWindow) { if (chatWindow) {
const messageElement = document.createElement("div"); const messageElement = document.createElement("div");
// if (getUser()?.id !== `${data.message.id}`) {
console.log('==================> HERE');
messageElement.textContent = `${data.message.user}: ${data.message.text}`; messageElement.textContent = `${data.message.user}: ${data.message.text}`;
// } else {
// console.log('==================>AND HERE');
// messageElement.textContent = `here`;
// }
chatWindow.appendChild(messageElement); chatWindow.appendChild(messageElement);
chatWindow.scrollTop = chatWindow.scrollHeight; chatWindow.scrollTop = chatWindow.scrollHeight;
} }
@ -178,20 +171,13 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn
}); });
window.addEventListener("blur", () => { window.addEventListener("blur", () => {
// if (window.location.pathname !== "/app/chat" && !toggle) { bconnected.click();
// // bconnected.click(); console.log("%cWindow is not focused on /chat", color.red);
// console.log("%cWindow is not focused on /chat", color.red);
if (socket.id) if (socket.id)
windowStateHidden(); windowStateHidden();
// }); toggle = false;
toggle = false;
// }
}); });
setTitle('Chat Page'); setTitle('Chat Page');
// Listen for the 'connect' event // Listen for the 'connect' event
return { return {
@ -299,9 +285,6 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn
}); });
// Enter key to send message // Enter key to send message
sendtextbox!.addEventListener('keydown', (event) => { sendtextbox!.addEventListener('keydown', (event) => {
if (event.key === 'Enter') { 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 });
// addRoute('/chat/', handleChat, { bypass_auth: true });

View file

@ -14,8 +14,8 @@ CREATE TABLE IF NOT EXISTS blocked (
user TEXT NOT NULL, user TEXT NOT NULL,
blocked TEXT NOT NULL, blocked TEXT NOT NULL,
FOREIGN KEY(user) REFERENCES user(id); FOREIGN KEY(user) REFERENCES user(id)
FOREIGN KEY(blocked) REFERENCES user(id); FOREIGN KEY(blocked) REFERENCES user(id)
); );
CREATE UNIQUE INDEX IF NOT EXISTS idx_blocked_user_pair CREATE UNIQUE INDEX IF NOT EXISTS idx_blocked_user_pair