diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index ac10778..5e890a2 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -466,7 +466,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn // //connected(socket); // },10000); // every 10 sec - socket.on('listBud', async (myBuddies: string) => { + socket.on('listBud', async (myBuddies: string[]) => { const buddies = document.getElementById('div-buddies') as HTMLDivElement; console.log('%cList buddies connected ',color.yellow, myBuddies); listBuddies(socket, buddies, myBuddies); @@ -610,4 +610,4 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn } } }; -addRoute('/chat', handleChat, { bypass_auth: true }); \ No newline at end of file +addRoute('/chat', handleChat, { bypass_auth: true }); diff --git a/frontend/src/pages/chat/listBuddies.ts b/frontend/src/pages/chat/listBuddies.ts index 6b53ea9..bb56a94 100644 --- a/frontend/src/pages/chat/listBuddies.ts +++ b/frontend/src/pages/chat/listBuddies.ts @@ -11,35 +11,38 @@ import { getProfil } from './getProfil'; * collected in the clipBoard * @param socket * @param buddies - * @param listBuddies + * @param bud * @returns */ -export async function listBuddies(socket: Socket, buddies: HTMLDivElement, listBuddies: string) { +export async function listBuddies(socket: Socket, buddies: HTMLDivElement, listBuddies: string[]) { - if (!buddies) return; - const sendtextbox = document.getElementById('t-chat-window') as HTMLButtonElement; - const buddiesElement = document.createElement("div-buddies-list"); - buddiesElement.textContent = listBuddies + '\n'; - const user = getUser()?.name ?? ""; - buddies.appendChild(buddiesElement); - buddies.scrollTop = buddies.scrollHeight; - console.log(`Added buddies: ${listBuddies}`); + buddies.innerHTML = ""; + for (const bud of listBuddies) + { + if (!buddies) return; + const sendtextbox = document.getElementById('t-chat-window') as HTMLButtonElement; + const buddiesElement = document.createElement("div-buddies-list"); + buddiesElement.textContent = bud + '\n'; + const user = getUser()?.name ?? ""; + buddies.appendChild(buddiesElement); + buddies.scrollTop = buddies.scrollHeight; + console.log(`Added buddies: ${bud}`); - buddiesElement.style.cursor = "pointer"; - buddiesElement.addEventListener("click", () => { - navigator.clipboard.writeText(listBuddies); - if (listBuddies !== user && user !== "") { - sendtextbox.value = `@${listBuddies}: `; - console.log("Copied to clipboard:", listBuddies); - sendtextbox.focus(); - } - }); - - buddiesElement.addEventListener("dblclick", () => { - console.log("Open profile:", listBuddies); - getProfil(socket, listBuddies); - sendtextbox.value = ""; - }); + buddiesElement.style.cursor = "pointer"; + buddiesElement.addEventListener("click", () => { + navigator.clipboard.writeText(bud); + if (bud !== user && user !== "") { + sendtextbox.value = `@${bud}: `; + console.log("Copied to clipboard:", bud); + sendtextbox.focus(); + } + }); + buddiesElement.addEventListener("dblclick", () => { + console.log("Open profile:", bud); + getProfil(socket, bud); + sendtextbox.value = ""; + }); + } } diff --git a/nginx/conf/locations/auth.conf b/nginx/conf/locations/auth.conf index cf8dfae..2f6a09e 100644 --- a/nginx/conf/locations/auth.conf +++ b/nginx/conf/locations/auth.conf @@ -1,4 +1,4 @@ #forward the post request to the microservice location /api/auth/ { - proxy_pass http://auth; + proxy_pass http://app-auth; } diff --git a/nginx/conf/locations/chat.conf b/nginx/conf/locations/chat.conf index 3500e4c..48a4416 100644 --- a/nginx/conf/locations/chat.conf +++ b/nginx/conf/locations/chat.conf @@ -1,6 +1,6 @@ #forward the post request to the microservice location /api/chat/ { - proxy_pass http://chat; + proxy_pass http://app-chat; } location /api/chat/socket.io/ { @@ -10,5 +10,5 @@ location /api/chat/socket.io/ { proxy_set_header Connection "Upgrade"; proxy_set_header Host $host; proxy_read_timeout 3600s; - proxy_pass http://chat; + proxy_pass http://app-chat; } diff --git a/nginx/conf/locations/user.conf b/nginx/conf/locations/user.conf index f267d74..f3e616f 100644 --- a/nginx/conf/locations/user.conf +++ b/nginx/conf/locations/user.conf @@ -1,4 +1,4 @@ #forward the post request to the microservice location /api/user/ { - proxy_pass http://user; + proxy_pass http://app-user; } diff --git a/src/chat/src/connectedUser.ts b/src/chat/src/connectedUser.ts index 6f63a88..a030a7e 100644 --- a/src/chat/src/connectedUser.ts +++ b/src/chat/src/connectedUser.ts @@ -13,6 +13,7 @@ export function connectedUser(io?: Server, target?: string): number { let count = 0; const seen = new Set(); // <- only log/count unique usernames + const listBud: string[] = []; for (const [socketId, username] of clientChat) { // Basic checks if (typeof socketId !== 'string' || socketId.length === 0) { @@ -38,11 +39,15 @@ export function connectedUser(io?: Server, target?: string): number { // socket exists and is connected seen.add(username.user); count++; - const targetSocketId = target; - io.to(targetSocketId!).emit('listBud', username.user); + // const targetSocketId = target; + // io.to(targetSocketId!).emit('listBud', username.user); + listBud.push(username.user); continue; } count++; } + if (io && typeof io.sockets?.sockets?.get === 'function' && target) { + io.to(target).emit('listBud', listBud); + } return count; -} \ No newline at end of file +} diff --git a/src/icons/entrypoint.sh b/src/icons/entrypoint.sh deleted file mode 100644 index 2dcab02..0000000 --- a/src/icons/entrypoint.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -set -e -set -x -# do anything here - -# run the CMD [ ... ] from the dockerfile -exec "$@" diff --git a/src/icons/openapi.json b/src/icons/openapi.json deleted file mode 100644 index 38cd725..0000000 --- a/src/icons/openapi.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "openapi": "3.1.0", - "info": { - "version": "9.6.1", - "title": "@fastify/swagger" - }, - "components": { - "schemas": {} - }, - "paths": {}, - "servers": [ - { - "url": "https://local.maix.me:8888", - "description": "direct from docker" - }, - { - "url": "https://local.maix.me:8000", - "description": "using fnginx" - } - ] -} diff --git a/src/icons/tsconfig.json b/src/icons/tsconfig.json deleted file mode 100644 index a731182..0000000 --- a/src/icons/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -// { -// "extends": "../tsconfig.base.json", -// "compilerOptions": { -// "skipLibCheck": true, // skips type checking for all .d.ts files -// "moduleResolution": "node", -// "esModuleInterop": true, -// "types": ["node"] }, -// "include": ["src/**/*.ts"] -// } - -{ - "extends": "../tsconfig.base.json", - "compilerOptions": {}, - "include": ["src/**/*.ts"] -}