Added function to buttun friend actionBtnFriend

This commit is contained in:
NigeParis 2026-01-16 15:47:25 +01:00 committed by Maix0
parent c547c2301f
commit 95784c9719
2 changed files with 29 additions and 0 deletions

View file

@ -29,6 +29,7 @@ import { windowStateVisable } from "./chatHelperFunctions/windowStateVisable";
import { cmdList } from "./chatHelperFunctions/cmdList"; import { cmdList } from "./chatHelperFunctions/cmdList";
import { actionBtnTTTGames } from "./chatHelperFunctions/actionBtnTTTGames"; import { actionBtnTTTGames } from "./chatHelperFunctions/actionBtnTTTGames";
import { showError } from "@app/toast"; import { showError } from "@app/toast";
import { actionBtnFriend } from "./chatHelperFunctions/actionBtnFriend";
const MAX_SYSTEM_MESSAGES = 10; const MAX_SYSTEM_MESSAGES = 10;
let inviteMsgFlag: boolean = false; let inviteMsgFlag: boolean = false;
@ -256,6 +257,7 @@ function initChatSocket() {
actionBtnPopUpBlock(profil, socket); actionBtnPopUpBlock(profil, socket);
actionBtnPongGames(profil, socket); actionBtnPongGames(profil, socket);
actionBtnTTTGames(profil, socket); actionBtnTTTGames(profil, socket);
actionBtnFriend(profil, socket);
}); });
socket.on("blockUser", (blocked: ClientProfil) => { socket.on("blockUser", (blocked: ClientProfil) => {

View file

@ -0,0 +1,27 @@
import type { ClientProfil } from "../types_front";
import { Socket } from "socket.io-client";
/**
* function listens for a click on the TTT game History button
* @param profile - Clients target profil
* @param senderSocket - socket from the sender
**/
export function actionBtnFriend(profile: ClientProfil, senderSocket: Socket) {
setTimeout(() => {
const friend = document.querySelector("#btn-friend");
friend?.addEventListener("click", () => {
if (friend.textContent = "friend") {
friend.textContent = "not-friend"
console.log('friend');
}
else {
friend.textContent = "not-friend"
console.log('Not a friend');
}
});
}, 0)
};