From daf5eb0564d9f6c1f35920b0d9ba5c767e770700 Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Wed, 18 Jun 2025 01:40:57 +0530 Subject: [PATCH 1/2] fix: room members count includes deactive users Signed-off-by: Abhinav Kumar --- app/views/RoomActionsView/index.tsx | 33 ++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/app/views/RoomActionsView/index.tsx b/app/views/RoomActionsView/index.tsx index 7f42a207ae1..2d0ea955f16 100644 --- a/app/views/RoomActionsView/index.tsx +++ b/app/views/RoomActionsView/index.tsx @@ -5,7 +5,7 @@ import isEmpty from 'lodash/isEmpty'; import React from 'react'; import { Share, Text, View } from 'react-native'; import { connect } from 'react-redux'; -import { Observable, Subscription } from 'rxjs'; +import { Observable, pairwise, Subscription } from 'rxjs'; import { CompositeNavigationProp } from '@react-navigation/native'; import { leaveRoom } from '../../actions/room'; @@ -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 Date: Wed, 18 Jun 2025 01:44:38 +0530 Subject: [PATCH 2/2] minor change Signed-off-by: Abhinav Kumar --- app/views/RoomActionsView/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/RoomActionsView/index.tsx b/app/views/RoomActionsView/index.tsx index 2d0ea955f16..ddae8ff7d99 100644 --- a/app/views/RoomActionsView/index.tsx +++ b/app/views/RoomActionsView/index.tsx @@ -5,7 +5,7 @@ import isEmpty from 'lodash/isEmpty'; import React from 'react'; import { Share, Text, View } from 'react-native'; import { connect } from 'react-redux'; -import { Observable, pairwise, Subscription } from 'rxjs'; +import { Observable, Subscription } from 'rxjs'; import { CompositeNavigationProp } from '@react-navigation/native'; import { leaveRoom } from '../../actions/room';