member_notif_ok
This commit is contained in:
parent
0af53f4e27
commit
6c8ef54f47
@ -214,25 +214,43 @@ class ChatElement extends HTMLElement {
|
|||||||
|
|
||||||
|
|
||||||
// Add notification
|
// Add notification
|
||||||
private addNotification(memberId: string, message: any) {
|
private async addNotification(memberId: string, message: any) {
|
||||||
let notificationText = '';
|
try {
|
||||||
if (message.type === 'file') {
|
// Obtenir l'emoji de l'adresse
|
||||||
notificationText = `New file from Member ${memberId}: ${message.fileName}`;
|
const memberEmoji = await addressToEmoji(memberId);
|
||||||
} else {
|
|
||||||
notificationText = `New message from Member ${memberId}: ${message.text}`;
|
// 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 {
|
public isPaired(): boolean {
|
||||||
@ -474,7 +492,6 @@ class ChatElement extends HTMLElement {
|
|||||||
this.messagesMock = messageStore.getMessages();
|
this.messagesMock = messageStore.getMessages();
|
||||||
this.loadMemberChat(this.selectedMemberId!);
|
this.loadMemberChat(this.selectedMemberId!);
|
||||||
|
|
||||||
// Ajouter la notification UNIQUEMENT pour la réponse reçue
|
|
||||||
this.addNotification(this.selectedMemberId!, autoReply);
|
this.addNotification(this.selectedMemberId!, autoReply);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user