[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>
`;
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);
}
}