From 7f6eabaa90838dfcc06f7628ccf5e3323ae6c8a8 Mon Sep 17 00:00:00 2001 From: NicolasCantu Date: Mon, 3 Mar 2025 17:17:54 +0100 Subject: [PATCH] Remove unnecessary async for getRoles --- src/pages/chat/chat.ts | 8 ++++---- src/services/service.ts | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/chat/chat.ts b/src/pages/chat/chat.ts index 7b3a240..2d4f612 100755 --- a/src/pages/chat/chat.ts +++ b/src/pages/chat/chat.ts @@ -396,7 +396,7 @@ class ChatElement extends HTMLElement { const processRoles = this.processRoles; const selectedMember = this.selectedMember; for (const child of children) { - const roles = await service.getRoles(JSON.parse(child)); + const roles = service.getRoles(JSON.parse(child)); // Check that we and the other members are in the role if (!service.isChildRole(processRoles, roles)) { console.error('Child process roles are not a subset of parent') @@ -539,7 +539,7 @@ class ChatElement extends HTMLElement { if (!description || description !== "dm") { continue; } - const roles = await service.getRoles(process); + const roles = service.getRoles(process); if (!service.rolesContainsMember(roles, recipientAddresses)) { console.error('Member is not part of the process'); continue; @@ -569,7 +569,7 @@ class ChatElement extends HTMLElement { if (!description || description !== "dm") { continue; } - const roles = await service.getRoles(process); + const roles = service.getRoles(process); const members = roles.dm.members; for (const member of members) {; if (!service.compareMembers(member.sp_addresses, myAddresses)) { @@ -1367,7 +1367,7 @@ class ChatElement extends HTMLElement { console.log("Process récupéré:", process); // Récupérer les rôles directement depuis le dernier état - const roles = await service.getRoles(process); + const roles = service.getRoles(process); console.log("Roles trouvés:", roles); if (!roles) return []; diff --git a/src/services/service.ts b/src/services/service.ts index 96db0df..412df6e 100755 --- a/src/services/service.ts +++ b/src/services/service.ts @@ -400,7 +400,7 @@ export default class Services { public async updateProcess(process: Process, new_state: any, roles: Record | null): Promise { // If roles is null, we just take the last commited state roles if (!roles) { - roles = await this.getRoles(process); + roles = this.getRoles(process); } else { // We should check that we have the right to change the roles here, or maybe it's better leave it to the wasm console.log('Provided new roles:', JSON.stringify(roles)); @@ -1179,7 +1179,7 @@ export default class Services { } - public async getRoles(process: Process): Promise | null> { + public getRoles(process: Process): Record | null { const lastCommitedState = this.getLastCommitedState(process); if (lastCommitedState && lastCommitedState.roles && Object.keys(lastCommitedState.roles).length != 0) { return lastCommitedState!.roles; @@ -1198,7 +1198,7 @@ export default class Services { continue; } try { - const roles = await this.getRoles(process); + const roles = this.getRoles(process); if (this.rolesContainsUs(roles)) { this.myProcesses.add(processId);