Chat Overlay on global site done - needs to have chat hide still
This commit is contained in:
parent
d3bd2fce22
commit
cd03048cb3
5 changed files with 38 additions and 31 deletions
|
|
@ -4,6 +4,7 @@ import cookie from "js-cookie";
|
||||||
import { ensureWindowState } from "@app/utils";
|
import { ensureWindowState } from "@app/utils";
|
||||||
import { navigateTo } from "./routing";
|
import { navigateTo } from "./routing";
|
||||||
|
|
||||||
|
|
||||||
cookie.remove("pkce");
|
cookie.remove("pkce");
|
||||||
const headerProfile =
|
const headerProfile =
|
||||||
document.querySelector<HTMLDivElement>("#header-profile")!;
|
document.querySelector<HTMLDivElement>("#header-profile")!;
|
||||||
|
|
|
||||||
|
|
@ -393,7 +393,7 @@ clearText?.addEventListener("click", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
bquit?.addEventListener("click", () => {
|
bquit?.addEventListener("click", () => {
|
||||||
showInfo('Nigel close the chat overlay please')
|
quitChat(socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Enter key to send message
|
// Enter key to send message
|
||||||
|
|
@ -418,3 +418,8 @@ chatButton!.addEventListener("click", () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.addEventListener('click', () => {
|
||||||
|
if (socket) {
|
||||||
|
connected(socket);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -6,27 +6,28 @@ import { updateUser } from "@app/auth";
|
||||||
/**
|
/**
|
||||||
* function displays who is logged in the chat in the ping-Bubbies window
|
* function displays who is logged in the chat in the ping-Bubbies window
|
||||||
* @param socket
|
* @param socket
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export async function connected(socket: Socket): Promise<void> {
|
export async function connected(socket: Socket): Promise<void> {
|
||||||
|
|
||||||
|
const buddies = document.getElementById('div-buddies') as HTMLDivElement;
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
try {
|
try {
|
||||||
const buddies = document.getElementById('div-buddies') as HTMLDivElement;
|
let oldUser = localStorage.getItem("oldName") ?? "";
|
||||||
const loggedIn = isLoggedIn();
|
let user = await updateUser();
|
||||||
if (!loggedIn) throw('Not Logged in');
|
const loggedIn = isLoggedIn();
|
||||||
let oldUser = localStorage.getItem("oldName") ?? "";
|
if (!loggedIn) throw('Not Logged in');
|
||||||
if (loggedIn?.name === undefined) {return ;};
|
if (loggedIn?.name === undefined) {return ;};
|
||||||
oldUser = loggedIn.name ?? "";
|
oldUser = loggedIn.name ?? "";
|
||||||
let user = await updateUser();
|
localStorage.setItem("oldName", oldUser);
|
||||||
localStorage.setItem("oldName", oldUser);
|
socket.emit('list', {
|
||||||
buddies.textContent = "";
|
oldUser: oldUser,
|
||||||
socket.emit('list', {
|
user: user?.name,
|
||||||
oldUser: oldUser,
|
});
|
||||||
user: user?.name,
|
socket.connect();
|
||||||
});
|
} catch (e) {
|
||||||
} catch (e) {
|
buddies.textContent = "";
|
||||||
showError('Failed to login: Unknown error');
|
socket.disconnect();
|
||||||
}
|
}
|
||||||
}, 16);
|
}, 16);
|
||||||
};
|
};
|
||||||
|
|
@ -8,22 +8,22 @@ import { setTitle } from "@app/routing";
|
||||||
/**
|
/**
|
||||||
* function to quit the chat - leaves the ping-Buddies list
|
* function to quit the chat - leaves the ping-Buddies list
|
||||||
* @param socket
|
* @param socket
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function quitChat (socket: Socket) {
|
export function quitChat (socket: Socket) {
|
||||||
|
const chatBox = document.getElementById("chatBox")!;
|
||||||
|
const overlay = document.querySelector('#overlay')!;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const systemWindow = document.getElementById('system-box') as HTMLDivElement;
|
if (chatBox.classList.contains('hidden')) {
|
||||||
const chatWindow = document.getElementById("t-chatbox") as HTMLDivElement;
|
// chatBox.classList.toggle('hidden');
|
||||||
if (socket) {
|
// overlay.classList.add('opacity-60');
|
||||||
logout(socket);
|
|
||||||
setTitle('Chat Page');
|
|
||||||
connected(socket);
|
|
||||||
} else {
|
} else {
|
||||||
getSocket();
|
chatBox.classList.toggle('hidden');
|
||||||
|
overlay.classList.remove('opacity-60');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showError('Failed to Quit Chat: Unknown error');
|
showError('Failed to Quit Chat: Unknown error');
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="bg-gradient-to-br from-slate-50 to-slate-100 text-slate-800">
|
<div class="bg-linear-to-br from-slate-50 to-slate-100 text-slate-800">
|
||||||
|
|
||||||
<!-- Hero -->
|
<!-- Hero -->
|
||||||
<section class="max-w-7xl mx-auto px-6 py-20 grid lg:grid-cols-2 gap-12 items-center">
|
<section class="max-w-7xl mx-auto px-6 py-20 grid lg:grid-cols-2 gap-12 items-center">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue