[bug] await all call of loadMemberChat

This commit is contained in:
NicolasCantu 2025-01-15 12:58:59 +01:00
parent 28883062db
commit be030f1981

View File

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