fix_coquille

This commit is contained in:
Pascal 2025-01-20 11:10:22 +01:00
parent 5f2e123b9d
commit b6df4dc5e3

View File

@ -402,9 +402,9 @@ class ChatElement extends HTMLElement {
} }
const res = await service.createDmProcess(member, this.processId); const res = await service.createDmProcess(member, this.processId);
// We catch the new process here // We catch the new process here
const updatedProcess = res.updated_process.current_process; const updatedProcess = res.updated_process?.current_process;
const processId = updatedProcess.states[0].commited_in; const processId = updatedProcess?.states[0]?.commited_in;
const stateId = updatedProcess.states[0].state_id; const stateId = updatedProcess?.states[0]?.state_id;
await service.handleApiReturn(res); await service.handleApiReturn(res);
setTimeout(async () => { setTimeout(async () => {
// Now create a first commitment // Now create a first commitment
@ -444,8 +444,8 @@ class ChatElement extends HTMLElement {
console.log(messagesProcess); console.log(messagesProcess);
const childProcess = JSON.parse(messagesProcess); const childProcess = JSON.parse(messagesProcess);
if (messagesProcess?.states) { if (childProcess?.states) {
for (const state of messagesProcess.states) { for (const state of childProcess.states) {
const pcd_commitment = state.pcd_commitment; const pcd_commitment = state.pcd_commitment;
if (pcd_commitment) { if (pcd_commitment) {
const message_hash = pcd_commitment.message; const message_hash = pcd_commitment.message;
@ -635,7 +635,17 @@ class ChatElement extends HTMLElement {
return null; return null;
} }
public async loadAllGroupList(): Promise<void> { //Load all processes
private async loadAllProcesses() {
console.log('🎯 Loading all processes');
const service = await Services.getInstance();
const processes = await service.getProcesses();
return processes;
}
// Load the group list from all processes
public async loadAllGroupListFromMyProcess(): Promise<void> {
console.log('🎯 Loading all group list'); console.log('🎯 Loading all group list');
const groupList = this.shadowRoot?.querySelector('#group-list'); const groupList = this.shadowRoot?.querySelector('#group-list');
if (!groupList) { if (!groupList) {
@ -657,6 +667,7 @@ class ChatElement extends HTMLElement {
} }
} }
// Load the group list from a process
private async loadGroupListFromAProcess(processId: string): Promise<void> { private async loadGroupListFromAProcess(processId: string): Promise<void> {
console.log('Loading group list with processId:', processId); console.log('Loading group list with processId:', processId);
const groupList = this.shadowRoot?.querySelector('#group-list'); const groupList = this.shadowRoot?.querySelector('#group-list');
@ -966,7 +977,8 @@ class ChatElement extends HTMLElement {
this.loadGroupListFromAProcess(this.processId); this.loadGroupListFromAProcess(this.processId);
} else if(this.processId == null){ } else if(this.processId == null){
console.error('❌ No process ID found in element attributes'); console.error('❌ No process ID found in element attributes');
this.loadAllGroupList(); //this.loadAllGroupListFromMyProcess();
this.loadAllProcesses();
} }
// Si un membre est sélectionné par défaut, charger ses messages // Si un membre est sélectionné par défaut, charger ses messages