From fd3b8dda2cdb5031e7794d6cf9e5d766ad9d6057 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Sun, 22 Nov 2020 12:40:03 +0100 Subject: [PATCH] Fix report button on anonymous connection --- front/src/Connexion/ConnectionManager.ts | 6 ++++++ front/src/WebRtc/DiscussionManager.ts | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 6f3aad04..f99cb223 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -12,12 +12,14 @@ const URL_ROOM_STARTED = '/Floor0/floor0.json'; class ConnectionManager { private localUser!:LocalUser; + private connexionType?: GameConnexionTypes /** * Tries to login to the node server and return the starting map url to be loaded */ public async initGameConnexion(): Promise { const connexionType = urlManager.getGameConnexionType(); + this.connexionType = connexionType; if(connexionType === GameConnexionTypes.register) { const organizationMemberToken = urlManager.getOrganizationToken(); const data = await Axios.post(`${API_URL}/register`, {organizationMemberToken}).then(res => res.data); @@ -108,6 +110,10 @@ class ConnectionManager { }); }); } + + get getConnexionType(){ + return this.connexionType; + } } export const connectionManager = new ConnectionManager(); diff --git a/front/src/WebRtc/DiscussionManager.ts b/front/src/WebRtc/DiscussionManager.ts index 097bf3a3..053a2f44 100644 --- a/front/src/WebRtc/DiscussionManager.ts +++ b/front/src/WebRtc/DiscussionManager.ts @@ -1,6 +1,9 @@ import {HtmlUtils} from "./HtmlUtils"; import {MediaManager, ReportCallback, UpdatedLocalStreamCallback} from "./MediaManager"; import {UserInputManager} from "../Phaser/UserInput/UserInputManager"; +import {connectionManager} from "../Connexion/ConnectionManager"; +import {GameConnexionTypes} from "../Url/UrlManager"; + export type SendMessageCallback = (message:string) => void; export class DiscussionManager { @@ -115,7 +118,11 @@ export class DiscussionManager { divParticipant.appendChild(divImgParticipant); divParticipant.appendChild(divPParticipant); - if(!isMe) { + if( + !isMe + && connectionManager.getConnexionType + && connectionManager.getConnexionType !== GameConnexionTypes.anonymous + ) { const reportBanUserAction: HTMLButtonElement = document.createElement('button'); reportBanUserAction.classList.add('report-btn') reportBanUserAction.innerText = 'Report';