diff --git a/src/pages/chat/chat.ts b/src/pages/chat/chat.ts index 30c9132..4c63f95 100755 --- a/src/pages/chat/chat.ts +++ b/src/pages/chat/chat.ts @@ -552,7 +552,7 @@ class ChatElement extends HTMLElement { const process = await service.getProcess(processId); console.log(process); const state = process.states[0]; // We assume that description never change and that we are part of the process from the beginning - const description = await service.decryptAttribute(state, 'description'); + const description = await service.decryptAttribute(processId, state, 'description'); console.log(description); if (!description || description !== "dm") { continue; @@ -583,7 +583,7 @@ class ChatElement extends HTMLElement { for (const processId of processes) { const process = await service.getProcess(processId); const state = process.states[0]; - const description = await service.decryptAttribute(state, 'description'); + const description = await service.decryptAttribute(processId, state, 'description'); if (!description || description !== "dm") { continue; } @@ -704,25 +704,25 @@ class ChatElement extends HTMLElement { // Récupérer les messages depuis les états du processus const allMessages: any[] = []; - const dmProcess = await service.getProcess(dmProcessId); + const dmProcess = await service.getProcess(this.selectedChatProcessId); console.log(dmProcess); if (dmProcess?.states) { for (const state of dmProcess.states) { - const pcd_commitment = state.pcd_commitment; - const message = await service.decryptAttribute(state, 'message'); + if (state.state_id === '') { continue; } + const message = await service.decryptAttribute(this.selectedChatProcessId, state, 'message'); if (message === "" || message === undefined || message === null) { - continue; - } - console.log('message', message); - allMessages.push(message); - } + continue; } + console.log('message', message); + allMessages.push(message); + } + } - allMessages.sort((a, b) => a.metadata.createdAt - b.metadata.createdAt); if (allMessages.length > 0) { console.log('Messages found:', allMessages); + allMessages.sort((a, b) => a.metadata.createdAt - b.metadata.createdAt); for (const message of allMessages) { const messageElement = document.createElement('div'); messageElement.className = 'message-container'; @@ -837,8 +837,8 @@ class ChatElement extends HTMLElement { if (dmProcess?.states) { for (const state of dmProcess.states) { - const pcd_commitment = state.pcd_commitment; - const message = await service.decryptAttribute(state, 'message'); + if (!state.state_id) { continue; } + const message = await service.decryptAttribute(dmProcessId, state, 'message'); if (message === "" || message === undefined || message === null) { continue; } @@ -1143,7 +1143,8 @@ class ChatElement extends HTMLElement { continue; } - const processName = service.getProcessName(process); + const publicData = service.getPublicData(process); + const processName = publicData['processName']; const emoji = await addressToEmoji(processId); let displayName;