Remove unnecessary async for getRoles
This commit is contained in:
parent
8f34f2bcbe
commit
7f6eabaa90
@ -396,7 +396,7 @@ class ChatElement extends HTMLElement {
|
|||||||
const processRoles = this.processRoles;
|
const processRoles = this.processRoles;
|
||||||
const selectedMember = this.selectedMember;
|
const selectedMember = this.selectedMember;
|
||||||
for (const child of children) {
|
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
|
// Check that we and the other members are in the role
|
||||||
if (!service.isChildRole(processRoles, roles)) {
|
if (!service.isChildRole(processRoles, roles)) {
|
||||||
console.error('Child process roles are not a subset of parent')
|
console.error('Child process roles are not a subset of parent')
|
||||||
@ -539,7 +539,7 @@ class ChatElement extends HTMLElement {
|
|||||||
if (!description || description !== "dm") {
|
if (!description || description !== "dm") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const roles = await service.getRoles(process);
|
const roles = service.getRoles(process);
|
||||||
if (!service.rolesContainsMember(roles, recipientAddresses)) {
|
if (!service.rolesContainsMember(roles, recipientAddresses)) {
|
||||||
console.error('Member is not part of the process');
|
console.error('Member is not part of the process');
|
||||||
continue;
|
continue;
|
||||||
@ -569,7 +569,7 @@ class ChatElement extends HTMLElement {
|
|||||||
if (!description || description !== "dm") {
|
if (!description || description !== "dm") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const roles = await service.getRoles(process);
|
const roles = service.getRoles(process);
|
||||||
const members = roles.dm.members;
|
const members = roles.dm.members;
|
||||||
for (const member of members) {;
|
for (const member of members) {;
|
||||||
if (!service.compareMembers(member.sp_addresses, myAddresses)) {
|
if (!service.compareMembers(member.sp_addresses, myAddresses)) {
|
||||||
@ -1367,7 +1367,7 @@ class ChatElement extends HTMLElement {
|
|||||||
console.log("Process récupéré:", process);
|
console.log("Process récupéré:", process);
|
||||||
|
|
||||||
// Récupérer les rôles directement depuis le dernier état
|
// 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);
|
console.log("Roles trouvés:", roles);
|
||||||
|
|
||||||
if (!roles) return [];
|
if (!roles) return [];
|
||||||
|
@ -400,7 +400,7 @@ export default class Services {
|
|||||||
public async updateProcess(process: Process, new_state: any, roles: Record<string, RoleDefinition> | null): Promise<ApiReturn> {
|
public async updateProcess(process: Process, new_state: any, roles: Record<string, RoleDefinition> | null): Promise<ApiReturn> {
|
||||||
// If roles is null, we just take the last commited state roles
|
// If roles is null, we just take the last commited state roles
|
||||||
if (!roles) {
|
if (!roles) {
|
||||||
roles = await this.getRoles(process);
|
roles = this.getRoles(process);
|
||||||
} else {
|
} else {
|
||||||
// We should check that we have the right to change the roles here, or maybe it's better leave it to the wasm
|
// 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));
|
console.log('Provided new roles:', JSON.stringify(roles));
|
||||||
@ -1179,7 +1179,7 @@ export default class Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async getRoles(process: Process): Promise<record<string, RoleDefinition> | null> {
|
public getRoles(process: Process): Record<string, RoleDefinition> | null {
|
||||||
const lastCommitedState = this.getLastCommitedState(process);
|
const lastCommitedState = this.getLastCommitedState(process);
|
||||||
if (lastCommitedState && lastCommitedState.roles && Object.keys(lastCommitedState.roles).length != 0) {
|
if (lastCommitedState && lastCommitedState.roles && Object.keys(lastCommitedState.roles).length != 0) {
|
||||||
return lastCommitedState!.roles;
|
return lastCommitedState!.roles;
|
||||||
@ -1198,7 +1198,7 @@ export default class Services {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const roles = await this.getRoles(process);
|
const roles = this.getRoles(process);
|
||||||
|
|
||||||
if (this.rolesContainsUs(roles)) {
|
if (this.rolesContainsUs(roles)) {
|
||||||
this.myProcesses.add(processId);
|
this.myProcesses.add(processId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user