Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions app/views/RoomActionsView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
};
private roomObservable?: Observable<TSubscriptionModel>;
private subscription?: Subscription;
private prevUsersCount?: number;

static navigationOptions = ({
navigation,
Expand Down Expand Up @@ -156,22 +157,38 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
hasE2EEWarning: false,
loading: false
};
this.prevUsersCount = this.state.room.usersCount;

if (room && room.observe && room.rid) {
const { encryptionEnabled } = this.props;
this.roomObservable = room.observe();
this.subscription = this.roomObservable.subscribe(changes => {
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;
}
}
});
}
Expand Down Expand Up @@ -203,12 +220,12 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
}
}

if (room && room.t !== 'd' && (await this.canViewMembers())) {
if (room && (await this.canViewMembers())) {
try {
const counters = await Services.getRoomCounters(room.rid, room.t as any);
if (counters.success) {
await this.updateUsersCount(counters.members);
this.setState({ joined: counters.joined });
this.setState({ joined: counters.joined, membersCount: counters.members });
}
} catch (e) {
log(e);
Expand Down Expand Up @@ -356,7 +373,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction

// This method is executed only in componentDidMount and returns a value
// We save the state to read in render
const result = t === 'c' || t === 'p';
const result = t === 'c' || t === 'p' || t === 'd';
return result;
};

Expand Down