diff --git a/src/pages/chat/chat.ts b/src/pages/chat/chat.ts index d5a4818..aa18aa4 100755 --- a/src/pages/chat/chat.ts +++ b/src/pages/chat/chat.ts @@ -603,31 +603,17 @@ class ChatElement extends HTMLElement { groupList.innerHTML = ''; - const dbRequest = window.indexedDB.open('4nk'); - const db = await new Promise((resolve, reject) => { - dbRequest.onsuccess = () => resolve(dbRequest.result); - dbRequest.onerror = () => reject(dbRequest.error); - }); + this.processId = processId; + const service = await Services.getInstance(); + const process = await service.getProcess(this.processId); - const transaction = db.transaction(['processes'], 'readonly'); - const processStore = transaction.objectStore('processes'); - const processRequest = processStore.get(processId); - - const process = await new Promise((resolve, reject) => { - processRequest.onsuccess = () => { - console.log('🔍 Process found:', processRequest.result); - resolve(processRequest.result); - }; - processRequest.onerror = () => reject(processRequest.error); - }); - - if (!process?.states?.[0]?.encrypted_pcd?.roles) { - console.error('❌ Process structure invalid:', process); + const roles = await this.getRoles(process); + if (roles === null) { + console.error('no roles in process'); return; } - - const roles = process.states[0].encrypted_pcd.roles; - console.log('🔑 Roles found:', roles); + this.processRoles = roles; + console.log('🔑 Roles found:', this.processRoles); const li = document.createElement('li'); li.className = 'group-list-item';