diff --git a/app/views/RoomActionsView/index.tsx b/app/views/RoomActionsView/index.tsx index 7f42a207ae1..ddae8ff7d99 100644 --- a/app/views/RoomActionsView/index.tsx +++ b/app/views/RoomActionsView/index.tsx @@ -118,6 +118,7 @@ class RoomActionsView extends React.Component; private subscription?: Subscription; + private prevUsersCount?: number; static navigationOptions = ({ navigation, @@ -156,22 +157,38 @@ class RoomActionsView extends React.Component { + this.subscription = this.roomObservable.subscribe(async (changes) => { if (this.mounted) { const hasE2EEWarning = EncryptionUtils.hasE2EEWarning({ encryptionEnabled, E2EKey: room.E2EKey, roomEncrypted: room.encrypted }); - this.setState({ room: changes, membersCount: changes.usersCount, hasE2EEWarning }); + this.setState({ room: changes, hasE2EEWarning }); } else { // @ts-ignore this.state.room = changes; - // @ts-ignore - this.state.membersCount = changes.usersCount; + } + + + // If the previous users count changes, we will update it and the members count to the value from the room counter. + if (this.prevUsersCount !== changes.usersCount) { + const counters = await Services.getRoomCounters(room.rid, room.t as any); + if (counters.success) { + if (this.mounted) { + this.setState({ membersCount: counters.members }) + } else { + // @ts-ignore + this.state.membersCount = counters.members + } + this.updateUsersCount(counters.members) + this.prevUsersCount = changes.usersCount; + } } }); } @@ -203,12 +220,12 @@ class RoomActionsView extends React.Component