From bff99d5c0b0e7bb5887496b54b72967dc6c64991 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Wed, 12 Jan 2022 11:04:15 -0300 Subject: [PATCH] [FIX] RoomInfoView displaying different info depending on the origin (#3586) Co-authored-by: GleidsonDaniel --- app/views/RoomInfoView/index.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/app/views/RoomInfoView/index.js b/app/views/RoomInfoView/index.js index a27083613..53c2c7d5a 100644 --- a/app/views/RoomInfoView/index.js +++ b/app/views/RoomInfoView/index.js @@ -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 + } } };