From 6c8ef54f477d36ddf12d283469b88be500eeeb4b Mon Sep 17 00:00:00 2001 From: Pascal Date: Thu, 9 Jan 2025 15:53:16 +0100 Subject: [PATCH] member_notif_ok --- src/pages/chat/chat.ts | 55 +++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/src/pages/chat/chat.ts b/src/pages/chat/chat.ts index 4b51f22..82acb6b 100755 --- a/src/pages/chat/chat.ts +++ b/src/pages/chat/chat.ts @@ -214,25 +214,43 @@ class ChatElement extends HTMLElement { // Add notification - private addNotification(memberId: string, message: any) { - let notificationText = ''; - if (message.type === 'file') { - notificationText = `New file from Member ${memberId}: ${message.fileName}`; - } else { - notificationText = `New message from Member ${memberId}: ${message.text}`; + private async addNotification(memberId: string, message: any) { + try { + // Obtenir l'emoji de l'adresse + const memberEmoji = await addressToEmoji(memberId); + + // Obtenir le processus et le rôle + const groupItem = this.shadowRoot?.querySelector('[data-process-id]'); + const processId = groupItem?.getAttribute('data-process-id'); + const processEmoji = processId ? await addressToEmoji(processId) : '📝'; + + // Trouver le rôle du membre + const member = this.allMembers.find(m => String(m.id) === memberId); + const role = member?.roleName || 'Member'; + + // Déterminer le texte de la notification + let notificationText = ''; + if (message.type === 'file') { + notificationText = `${memberEmoji} (${role}) in ${processEmoji}: New file - ${message.fileName}`; + } else { + notificationText = `${memberEmoji} (${role}) in ${processEmoji}: ${message.text}`; + } + + // Créer la notification + const notification = { + memberId, + text: notificationText, + time: message.time + }; + + // Ajouter la notification et mettre à jour l'interface + this.notifications.push(notification); + this.renderNotifications(); + this.updateNotificationBadge(); + + } catch (error) { + console.error('Error creating notification:', error); } - - // Creating a new notification - const notification = { - memberId, - text: notificationText, - time: message.time - }; - - // Added notification to list and interface - this.notifications.push(notification); - this.renderNotifications(); - this.updateNotificationBadge(); } public isPaired(): boolean { @@ -474,7 +492,6 @@ class ChatElement extends HTMLElement { this.messagesMock = messageStore.getMessages(); this.loadMemberChat(this.selectedMemberId!); - // Ajouter la notification UNIQUEMENT pour la réponse reçue this.addNotification(this.selectedMemberId!, autoReply); }, 1000);