Fix connectedCallback() to handle default selections

This commit is contained in:
NicolasCantu 2025-01-21 14:22:14 +01:00
parent ffca3725bf
commit 9d1e0e31c6

View File

@ -1192,21 +1192,25 @@ class ChatElement extends HTMLElement {
} }
async connectedCallback() { async connectedCallback() {
console.log('🔍 Connected Callback started'); this.processId = this.getAttribute('process-id');
console.log('🔍 Connected Callback started with', this.processId);
if (this.processId) { if (this.processId) {
console.log('🔍 Loading chat with process ID:', this.processId); console.log('🔍 Loading chat with process ID:', this.processId);
this.loadGroupListFromAProcess(this.processId); this.loadGroupListFromAProcess(this.processId);
} else if(this.processId == null){ } else {
console.error('❌ No process ID found in element attributes'); console.warn('⚠️ No process ID found. Loading default processes...');
//this.loadAllGroupListFromMyProcess();
this.loadAllProcesses(); await this.loadAllProcesses();
this.loadAllMembers(); await this.loadAllMembers();
} }
// Si un membre est sélectionné par défaut, charger ses messages
if (this.selectedMember) { if (this.selectedMember && this.selectedMember.length > 0) {
console.log('🔍 Loading chat for selected member:', this.selectedMember);
await this.loadMemberChat(this.selectedMember); await this.loadMemberChat(this.selectedMember);
} else {
console.warn('⚠️ No member selected yet. Waiting for selection...');
} }
} }