diff --git a/src/pages/chat/chat.ts b/src/pages/chat/chat.ts index 9344dc6..9942b1b 100755 --- a/src/pages/chat/chat.ts +++ b/src/pages/chat/chat.ts @@ -404,6 +404,33 @@ class ChatElement extends HTMLElement { groupList.appendChild(memberList); } + + private async lookForDmProcess(): Promise { + // Filter processes for the children of current process + const service = await Services.getInstance(); + const processes = await service.getProcesses(); + + const selectedMember = this.selectedMember; + for (const [processId, process] of Object.entries(processes)) { + const description = await service.getDescription(processId, process); + console.log('Process description:'description); + if (description !== "dm") { + continue; + } + const roles = await this.getRoles(process); + if (!service.rolesContainsMember(roles, selectedMember)) { + console.error('Member is not part of the process'); + continue; + } + if (!service.rolesContainsUs(roles)) { + console.error('We\'re not part of child process'); + continue; + } + return processId; + } + + return null; + } private async loadMemberChat(member: string[]) { if (member.length === 0) {