From 8b2a35dcce8572fcf9c229dde120749e9d924ad3 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Tue, 13 Jan 2026 18:04:18 +0100 Subject: [PATCH] Added message dot --- frontend/index.html | 1 + frontend/src/chat/chat.css | 19 +++++++++++++- frontend/src/chat/chat.ts | 25 +++++++++++-------- .../src/chat/chatHelperFunctions/quitChat.ts | 5 +++- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index c68ae22..59f7892 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -53,6 +53,7 @@
+
🔴
diff --git a/frontend/src/chat/chat.css b/frontend/src/chat/chat.css index 57df2b8..9aa3f24 100644 --- a/frontend/src/chat/chat.css +++ b/frontend/src/chat/chat.css @@ -130,7 +130,7 @@ top-4 left-6 } - +overlay .b-TTTgame { @apply absolute @@ -343,6 +343,23 @@ div-private { hover:bg-red-700 } +.chat-buttonMsg { + @apply + z-100 + align-text-top + text-xs + fixed bottom-15 + right-9 + w-2 + h-2 + z-300 + rounded-full + shadow-lg + flex items-center + justify-center + hover:bg-red-700 + +} .hidden{ diff --git a/frontend/src/chat/chat.ts b/frontend/src/chat/chat.ts index 4c5f1fc..2422745 100644 --- a/frontend/src/chat/chat.ts +++ b/frontend/src/chat/chat.ts @@ -7,13 +7,7 @@ import type { ClientProfilPartial, } from "./types_front"; import type { User } from "@app/auth"; -import { - addRoute, - navigateTo, - setTitle, - type RouteHandlerParams, - type RouteHandlerReturn, -} from "@app/routing"; +import { navigateTo } from "@app/routing"; import authHtml from "./chat.html?raw"; import { getUser } from "@app/auth"; import { listBuddies } from "./chatHelperFunctions/listBuddies"; @@ -33,7 +27,6 @@ import { quitChat } from "./chatHelperFunctions/quitChat"; import { openMessagePopup } from "./chatHelperFunctions/openMessagePopup"; import { windowStateVisable } from "./chatHelperFunctions/windowStateVisable"; import { cmdList } from "./chatHelperFunctions/cmdList"; -import { showInfo } from "../toast"; import { actionBtnTTTGames } from "./chatHelperFunctions/actionBtnTTTGames"; const MAX_SYSTEM_MESSAGES = 10; @@ -71,6 +64,7 @@ const buddies = document.getElementById("div-buddies") as HTMLDivElement; const buttonMessage = document.getElementById("close-modal-message") ?? null; const buttonPro = document.getElementById("close-modal") ?? null; const chatButton = document.querySelector("#chatButton"); +const chatMessageIn = document.querySelector("#chatMessageIn"); const chatWindow = document.querySelector("#t-chatbox")!; const clearText = document.getElementById("b-clear") as HTMLButtonElement; const gameMessage = document.getElementById("game-modal") ?? null; @@ -129,14 +123,18 @@ function initChatSocket() { systemWindow.appendChild(messageElement); systemWindow.scrollTop = systemWindow.scrollHeight; }); + chatMessageIn?.classList.add("hidden"); + // Listen for messages from the server "MsgObjectServer" socket.on("MsgObjectServer", (data: { message: ClientMessage }) => { if (socket) { connected(socket); } - + if (chatWindow && data.message.destination === "") { + chatMessageIn?.classList.remove("hidden"); + chatMessageIn!.textContent = '🔵'; const messageElement = document.createElement("div"); messageElement.textContent = `${data.message.user}: ${data.message.text}`; chatWindow.appendChild(messageElement); @@ -144,6 +142,8 @@ function initChatSocket() { } if (chatWindow && data.message.destination === "privateMsg") { + chatMessageIn?.classList.remove("hidden"); + chatMessageIn!.textContent = '🔴'; const messageElement = document.createElement("div-private"); messageElement.textContent = `🔒${data.message.user}: ${data.message.text}`; chatWindow.appendChild(messageElement); @@ -151,6 +151,8 @@ function initChatSocket() { } if (chatWindow && data.message.destination === "inviteMsg") { + chatMessageIn?.classList.remove("hidden"); + chatMessageIn!.textContent = '🟢'; const messageElement = document.createElement("div-private"); const chatWindow = document.getElementById( "t-chatbox", @@ -460,12 +462,15 @@ chatButton!.addEventListener("click",() => { windowStateVisable(); let socket = window.__state.chatSock; if (!socket) return; - connected(socket); + connected(socket); + chatMessageIn?.classList.add("hidden"); + chatMessageIn!.textContent = ''; } else { chatBox.classList.toggle("hidden"); overlay.classList.remove("opacity-60"); windowStateHidden(); + } }); diff --git a/frontend/src/chat/chatHelperFunctions/quitChat.ts b/frontend/src/chat/chatHelperFunctions/quitChat.ts index 6fd7e2c..2ab0150 100644 --- a/frontend/src/chat/chatHelperFunctions/quitChat.ts +++ b/frontend/src/chat/chatHelperFunctions/quitChat.ts @@ -10,7 +10,8 @@ import { windowStateHidden } from "./windowStateHidden"; export async function quitChat () { const chatBox = document.getElementById("chatBox")!; const overlay = document.querySelector('#overlay')!; - + const chatMessageIn = document.querySelector("#chatMessageIn"); + try { if (chatBox.classList.contains('hidden')) { // chatBox.classList.toggle('hidden'); @@ -21,6 +22,8 @@ export async function quitChat () { await windowStateHidden(); chatBox.classList.toggle('hidden'); overlay.classList.remove('opacity-60'); + chatMessageIn?.classList.remove("hidden"); + chatMessageIn!.textContent = ''; } } catch (e) { showError('Failed to Quit Chat: Unknown error');