diff --git a/src/pages/chat/chat.ts b/src/pages/chat/chat.ts index 27aeb51..87102c3 100755 --- a/src/pages/chat/chat.ts +++ b/src/pages/chat/chat.ts @@ -93,9 +93,9 @@ class ChatElement extends HTMLElement { `; window.toggleUserList = this.toggleUserList.bind(this); - window.loadMemberChat = (memberId: string | number) => { + window.loadMemberChat = async (memberId: string | number) => { if (typeof memberId === 'string') { - return this.loadMemberChat(memberId); + return await this.loadMemberChat(memberId); } else { console.error('Invalid memberId type. Expected string, got number.'); } @@ -186,9 +186,9 @@ class ChatElement extends HTMLElement { const notifElement = document.createElement('div'); notifElement.className = 'notification-item'; notifElement.textContent = `${notif.text} at ${notif.time}`; - notifElement.onclick = () => { - this.loadMemberChat(notif.memberId); - this.removeNotification(index); + notifElement.onclick = async () => { + await this.loadMemberChat(notif.memberId); + await this.removeNotification(index); }; this.notificationBoard?.appendChild(notifElement); }); @@ -844,7 +844,7 @@ class ChatElement extends HTMLElement { }); } - connectedCallback() { + async connectedCallback() { if (this.processId) { console.log('🔍 Loading chat with process ID:', this.processId); @@ -854,7 +854,7 @@ class ChatElement extends HTMLElement { } // Si un membre est sélectionné par défaut, charger ses messages if (this.selectedMemberId) { - this.loadMemberChat(this.selectedMemberId); + await this.loadMemberChat(this.selectedMemberId); } }