createTableOk
This commit is contained in:
parent
0af0af2d63
commit
5b0eb57edf
@ -55,8 +55,6 @@ class ChatElement extends HTMLElement {
|
|||||||
this.attachShadow({ mode: 'open' });
|
this.attachShadow({ mode: 'open' });
|
||||||
this.processId = this.getAttribute('process-id');
|
this.processId = this.getAttribute('process-id');
|
||||||
|
|
||||||
console.log('🔍 Constructor - Process ID from element:', this.processId);
|
|
||||||
|
|
||||||
this.shadowRoot!.innerHTML = `
|
this.shadowRoot!.innerHTML = `
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@ -714,7 +712,7 @@ class ChatElement extends HTMLElement {
|
|||||||
console.log('🎯 Loading all processes');
|
console.log('🎯 Loading all processes');
|
||||||
|
|
||||||
const processSet = this.userProcessesSet;
|
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');
|
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é
|
//fonction qui renvoie les processus où le sp_adress est impliqué
|
||||||
private async getProcessesWhereTheCurrentMemberIs() {
|
private async getProcessesWhereTheCurrentMemberIs() {
|
||||||
const processId = await this.getMyProcessId();
|
const service = await Services.getInstance();
|
||||||
if (!processId) return;
|
try {
|
||||||
this.processId = processId;
|
const currentMember = await service.getMemberFromDevice();
|
||||||
|
if (!currentMember) {
|
||||||
const processes = await this.getProcesses();
|
console.error('❌ Pas de membre trouvé');
|
||||||
const processSet = new Set<string>();
|
return 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);
|
|
||||||
}
|
}
|
||||||
|
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() {
|
async connectedCallback() {
|
||||||
this.processId = this.getAttribute('process-id');
|
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) {
|
if (this.selectedMember && this.selectedMember.length > 0) {
|
||||||
console.log('🔍 Loading chat for selected member:', this.selectedMember);
|
console.log('🔍 Loading chat for selected member:', this.selectedMember);
|
||||||
|
@ -1046,4 +1046,8 @@ export default class Services {
|
|||||||
console.log('🔍 Liste complète des membres:', Object.values(this.membersList));
|
console.log('🔍 Liste complète des membres:', Object.values(this.membersList));
|
||||||
return Object.values(this.membersList);
|
return Object.values(this.membersList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user