Fix getProcessesWhereTheCurrentMemberIs()

This commit is contained in:
NicolasCantu 2025-01-28 10:50:44 +01:00
parent 48aa9e4550
commit 4d428601b5

View File

@ -880,7 +880,6 @@ class ChatElement extends HTMLElement {
const service = await Services.getInstance(); const service = await Services.getInstance();
// Get the `commited_in` value of the last state and remove it from the array // Get the `commited_in` value of the last state and remove it from the array
const currentCommitedIn = process.states.pop()?.commited_in; const currentCommitedIn = process.states.pop()?.commited_in;
console.log('Current CommitedIn (roles):', currentCommitedIn);
if (currentCommitedIn === undefined) { if (currentCommitedIn === undefined) {
return null; // No states available return null; // No states available
@ -1153,11 +1152,21 @@ class ChatElement extends HTMLElement {
const memberEmoji = await addressToEmoji(pairingProcess); const memberEmoji = await addressToEmoji(pairingProcess);
console.log("Mon adresse:", currentMember[0], memberEmoji); console.log("Mon adresse:", currentMember[0], memberEmoji);
const processes = await this.getProcesses(); const processes = await service.getProcesses();
for (const {key, value} of processes) { for (const [processId, process] of Object.entries(processes)) {
const processName = await key; console.log(processId);
const roles = await value.states[0].encrypted_pcd.roles; console.log(process);
let roles;
try {
roles = await this.getRoles(process);
if (!roles) {
roles = await process.states[0].encrypted_pcd.roles;
}
} catch (e) {
console.error('Failed to get roles for process:', processId);
continue;
}
const hasCurrentUser = Object.values(roles).some(role => const hasCurrentUser = Object.values(roles).some(role =>
(role as { members: { sp_addresses: string[] }[] }).members (role as { members: { sp_addresses: string[] }[] }).members
@ -1165,8 +1174,8 @@ class ChatElement extends HTMLElement {
); );
if (hasCurrentUser) { if (hasCurrentUser) {
this.userProcessSet.add(processName); this.userProcessSet.add(processId);
console.log("Ajout du process au Set:", processName); console.log("Ajout du process au Set:", processId);
} }
} }
@ -1491,7 +1500,6 @@ class ChatElement extends HTMLElement {
await this.loadGroupListFromAProcess(this.processId); await this.loadGroupListFromAProcess(this.processId);
} else { } else {
console.log("🔍 Chargement des processus par défaut"); console.log("🔍 Chargement des processus par défaut");
await this.getProcessesWhereTheCurrentMemberIs();
const processSet = await this.getProcessesWhereTheCurrentMemberIs(); const processSet = await this.getProcessesWhereTheCurrentMemberIs();
await this.loadAllProcesses(processSet); await this.loadAllProcesses(processSet);
} }