Fixed in / out chat notification system info

This commit is contained in:
NigeParis 2026-01-13 11:04:37 +01:00 committed by Maix0
parent 2e422eee2a
commit 7e644fe658
7 changed files with 28 additions and 41 deletions

View file

@ -384,15 +384,18 @@ sendButton?.addEventListener("click", () => {
let toggle = false;
window.addEventListener("focus", async () => {
console.log('--------------------------')
console.log('Window focus called Called');
console.log('--------------------------')
setTimeout(() => {
if (window.__state.chatSock) connected(window.__state.chatSock);
}, 16);
if (window.location.pathname === "/app/chat") {
if (window.__state.chatSock?.id) {
// if (window.location.pathname === "/app/chat") {
// if (window.__state.chatSock?.id) {
await windowStateVisable();
}
// }
toggle = true;
}
// }
});
window.addEventListener("blur", () => {
@ -419,13 +422,17 @@ sendtextbox.addEventListener("keydown", (event) => {
}
});
chatButton!.addEventListener("click", () => {
chatButton!.addEventListener("click", async () => {
if (chatBox.classList.contains("hidden")) {
chatBox.classList.toggle("hidden");
overlay.classList.add("opacity-60");
await windowStateVisable();
} else {
chatBox.classList.toggle("hidden");
overlay.classList.remove("opacity-60");
await windowStateHidden();
}
});

View file

@ -28,14 +28,3 @@ export function addInviteMessage(text: string) {
chatWindow.scrollTop = chatWindow.scrollHeight;
return ;
};
// if (chatWindow && data.message.destination === "inviteMsg") {
// const messageElement = document.createElement("div-private");
// const chatWindow = document.getElementById(
// "t-chatbox",
// ) as HTMLDivElement;
// messageElement.innerHTML = `🏓${data.message.SenderUserName}: ${data.message.innerHtml}`;
// chatWindow.appendChild(messageElement);
// chatWindow.scrollTop = chatWindow.scrollHeight;
// }

View file

@ -1,16 +1,13 @@
import { Socket } from "socket.io-client";
import { getSocket } from "../chat";
import { logout } from "./logout";
import { connected } from "./connected";
import { showError } from "@app/toast";
import { setTitle } from "@app/routing";
import { windowStateVisable } from "./windowStateVisable";
import { windowStateHidden } from "./windowStateHidden";
/**
* function to quit the chat - leaves the ping-Buddies list
* @param socket
*
*/
export function quitChat () {
export async function quitChat () {
const chatBox = document.getElementById("chatBox")!;
const overlay = document.querySelector('#overlay')!;
@ -18,7 +15,10 @@ export function quitChat () {
if (chatBox.classList.contains('hidden')) {
// chatBox.classList.toggle('hidden');
// overlay.classList.add('opacity-60');
await windowStateVisable();
} else {
await windowStateHidden();
chatBox.classList.toggle('hidden');
overlay.classList.remove('opacity-60');
}

View file

@ -1,6 +1,9 @@
import { updateUser } from "@app/auth";
export async function windowStateHidden() {
console.log('--------------------------')
console.log('WindowState Hidden Called');
console.log('--------------------------')
const socketId = window.__state.chatSock || undefined;
// let oldName = localStorage.getItem("oldName") ?? undefined;
let oldName: string;

View file

@ -9,6 +9,9 @@ import { updateUser } from "@app/auth";
export async function windowStateVisable() {
console.log('--------------------------')
console.log('WindowState Visable Called');
console.log('--------------------------')
const buddies = document.getElementById('div-buddies') as HTMLDivElement;
const socketId = window.__state.chatSock || undefined;
let oldName = localStorage.getItem("oldName") || undefined;