notif_ok_but_id_ko
This commit is contained in:
parent
e1ee152fef
commit
0af53f4e27
@ -112,6 +112,15 @@ class ChatElement extends HTMLElement {
|
|||||||
window.toggleUserList = this.toggleUserList.bind(this);
|
window.toggleUserList = this.toggleUserList.bind(this);
|
||||||
window.loadMemberChat = this.loadMemberChat.bind(this);
|
window.loadMemberChat = this.loadMemberChat.bind(this);
|
||||||
|
|
||||||
|
|
||||||
|
this.notificationBadge = document.querySelector('.notification-badge');
|
||||||
|
this.notificationBoard = document.getElementById('notification-board');
|
||||||
|
this.notificationBell = document.getElementById('notification-bell');
|
||||||
|
|
||||||
|
if (!this.notificationBadge || !this.notificationBoard || !this.notificationBell) {
|
||||||
|
console.error('Notification elements not found');
|
||||||
|
}
|
||||||
|
|
||||||
// Initialiser les événements de notification
|
// Initialiser les événements de notification
|
||||||
document.addEventListener('click', (event: Event): void => {
|
document.addEventListener('click', (event: Event): void => {
|
||||||
if (this.notificationBoard && this.notificationBoard.style.display === 'block' &&
|
if (this.notificationBoard && this.notificationBoard.style.display === 'block' &&
|
||||||
@ -205,11 +214,18 @@ class ChatElement extends HTMLElement {
|
|||||||
|
|
||||||
|
|
||||||
// Add notification
|
// Add notification
|
||||||
private addNotification(memberId: string, message: Message) {
|
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}`;
|
||||||
|
}
|
||||||
|
|
||||||
// Creating a new notification
|
// Creating a new notification
|
||||||
const notification = {
|
const notification = {
|
||||||
memberId,
|
memberId,
|
||||||
text: `New message from Member ${memberId}: ${message.text}`,
|
text: notificationText,
|
||||||
time: message.time
|
time: message.time
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -457,6 +473,9 @@ class ChatElement extends HTMLElement {
|
|||||||
messageStore.addMessage(this.selectedMemberId!, autoReply);
|
messageStore.addMessage(this.selectedMemberId!, autoReply);
|
||||||
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);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -807,7 +826,7 @@ class ChatElement extends HTMLElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send a file
|
// Send a file
|
||||||
private sendFile(file: File) {
|
private async sendFile(file: File) {
|
||||||
if (!this.selectedMemberId) return;
|
if (!this.selectedMemberId) return;
|
||||||
|
|
||||||
const MAX_FILE_SIZE = 5 * 1024 * 1024;
|
const MAX_FILE_SIZE = 5 * 1024 * 1024;
|
||||||
@ -835,6 +854,17 @@ class ChatElement extends HTMLElement {
|
|||||||
|
|
||||||
const fileInput = this.shadowRoot?.querySelector('#file-input') as HTMLInputElement;
|
const fileInput = this.shadowRoot?.querySelector('#file-input') as HTMLInputElement;
|
||||||
if (fileInput) fileInput.value = '';
|
if (fileInput) fileInput.value = '';
|
||||||
|
|
||||||
|
// Générer la réponse automatique
|
||||||
|
setTimeout(() => {
|
||||||
|
const autoReply = this.generateAutoReply(this.selectedMemberId!);
|
||||||
|
messageStore.addMessage(this.selectedMemberId!, autoReply);
|
||||||
|
this.messagesMock = messageStore.getMessages();
|
||||||
|
this.loadMemberChat(this.selectedMemberId!);
|
||||||
|
|
||||||
|
// Ajouter la notification UNIQUEMENT pour la réponse reçue
|
||||||
|
this.addNotification(this.selectedMemberId!, autoReply);
|
||||||
|
}, 1000);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user