createTableOk

This commit is contained in:
Pascal 2025-01-22 14:30:26 +01:00
parent 0af0af2d63
commit 5b0eb57edf
2 changed files with 48 additions and 49 deletions

View File

@ -55,8 +55,6 @@ class ChatElement extends HTMLElement {
this.attachShadow({ mode: 'open' });
this.processId = this.getAttribute('process-id');
console.log('🔍 Constructor - Process ID from element:', this.processId);
this.shadowRoot!.innerHTML = `
<style>
@ -714,7 +712,7 @@ class ChatElement extends HTMLElement {
console.log('🎯 Loading all processes');
const processSet = this.userProcessesSet;
console.log("Je suis le processSet :" ,processSet);
console.log("Je suis le processSet dans loadAllProcesses :" ,processSet);
const dbRequest = indexedDB.open('4nk');
@ -876,45 +874,41 @@ class ChatElement extends HTMLElement {
});
}
//Load tous les processus où le sp_adress est impliqué et renvoie un tableau d'adresses de processus
private async getMyProcessId() {
const service = await Services.getInstance();
const myAddresses = await service.getMemberFromDevice();
if (!myAddresses) {
console.error('No paired member found');
return;
}
this.processId = myAddresses[0];
return this.processId;
}
//fonction qui renvoie les processus où le sp_adress est impliqué
private async getProcessesWhereTheCurrentMemberIs() {
const processId = await this.getMyProcessId();
if (!processId) return;
this.processId = processId;
const processes = await this.getProcesses();
const processSet = new Set<string>();
console.log("Je suis le processSet :" ,processSet);
for (const {key, value} of processes) {
const processName = await key;
const roles = await value.states[0].encrypted_pcd.roles;
const hasCurrentUser = this.processId && Object.values(roles).some(role =>
(role as { members: { sp_addresses: string[] }[] }).members
.some(member => member.sp_addresses.includes(this.processId!))
);
if (hasCurrentUser) {
processSet.add(processName);
const service = await Services.getInstance();
try {
const currentMember = await service.getMemberFromDevice();
if (!currentMember) {
console.error('❌ Pas de membre trouvé');
return new Set<string>();
}
console.log("Mon adresse:", currentMember[0]);
const processes = await this.getProcesses();
const processSet = new Set<string>();
for (const {key, value} of processes) {
const processName = await key;
const roles = await value.states[0].encrypted_pcd.roles;
const hasCurrentUser = Object.values(roles).some(role =>
(role as { members: { sp_addresses: string[] }[] }).members
.some(member => member.sp_addresses.includes(currentMember[0]))
);
if (hasCurrentUser) {
processSet.add(processName);
console.log("Ajout du process au Set:", processName);
}
}
console.log("Ensemble des processus :", processSet);
return processSet;
} catch (e) {
console.error('❌ Erreur:', e);
return new Set<string>();
}
console.log("Ensemble des processus :", processSet);
return processSet;
}
@ -1225,18 +1219,19 @@ class ChatElement extends HTMLElement {
async connectedCallback() {
this.processId = this.getAttribute('process-id');
console.log('🔍 Connected Callback started with', this.processId);
if (this.processId) {
console.log('🔍 Loading chat with process ID:', this.processId);
this.loadGroupListFromAProcess(this.processId);
} else {
console.warn('⚠️ No process ID found. Loading default processes...');
await this.loadAllProcesses();
const processSet = await this.getProcessesWhereTheCurrentMemberIs();
this.userProcessesSet = processSet || null;
}
//const processSet = await this.getProcessesWhereTheCurrentMemberIs();
//this.userProcessesSet = processSet || null;
//console.log("📋 ProcessSet chargé:", this.userProcessesSet);
if (this.processId) {
console.log("🔍 Chargement du chat avec processID");
await this.loadGroupListFromAProcess(this.processId);
} else {
console.log("🔍 Chargement des processus par défaut");
await this.loadAllProcesses();
await this.getProcessesWhereTheCurrentMemberIs();
}
if (this.selectedMember && this.selectedMember.length > 0) {
console.log('🔍 Loading chat for selected member:', this.selectedMember);

View File

@ -1046,4 +1046,8 @@ export default class Services {
console.log('🔍 Liste complète des membres:', Object.values(this.membersList));
return Object.values(this.membersList);
}
}