[FIX] RoomInfoView displaying different info depending on the origin (#3586)

Co-authored-by: GleidsonDaniel <gleidson10daniel@hotmail.com>
This commit is contained in:
Reinaldo Neto 2022-01-12 11:04:15 -03:00 committed by GitHub
parent cd9ce58660
commit bff99d5c0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 6 deletions

View File

@ -178,6 +178,14 @@ class RoomInfoView extends React.Component {
}
};
parseRoles = roleArray =>
Promise.all(
roleArray.map(async role => {
const description = await this.getRoleDescription(role);
return description;
})
);
loadUser = async () => {
const { room, roomUser } = this.state;
@ -189,12 +197,7 @@ class RoomInfoView extends React.Component {
const { user } = result;
const { roles } = user;
if (roles && roles.length) {
user.parsedRoles = await Promise.all(
roles.map(async role => {
const description = await this.getRoleDescription(role);
return description;
})
);
user.parsedRoles = await this.parseRoles(roles);
}
this.setState({ roomUser: user });
@ -202,6 +205,18 @@ class RoomInfoView extends React.Component {
} catch {
// do nothing
}
} else {
try {
const { roles } = roomUser;
if (roles && roles.length) {
const parsedRoles = await this.parseRoles(roles);
this.setState({ roomUser: { ...roomUser, parsedRoles } });
} else {
this.setState({ roomUser });
}
} catch (e) {
// do nothing
}
}
};