Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 0d8309c

Browse files
authored
Merge pull request #6429 from matrix-org/gsouquet/fix-18146
2 parents 6afa3fa + 26ca41f commit 0d8309c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/components/structures/MessagePanel.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ export default class MessagePanel extends React.Component<IProps, IState> {
236236
// A map of <callId, CallEventGrouper>
237237
private callEventGroupers = new Map<string, CallEventGrouper>();
238238

239+
private membersCount = 0;
240+
239241
constructor(props, context) {
240242
super(props, context);
241243

@@ -256,11 +258,14 @@ export default class MessagePanel extends React.Component<IProps, IState> {
256258
}
257259

258260
componentDidMount() {
261+
this.calculateRoomMembersCount();
262+
this.props.room?.on("RoomState.members", this.calculateRoomMembersCount);
259263
this.isMounted = true;
260264
}
261265

262266
componentWillUnmount() {
263267
this.isMounted = false;
268+
this.props.room?.off("RoomState.members", this.calculateRoomMembersCount);
264269
SettingsStore.unwatchSetting(this.showTypingNotificationsWatcherRef);
265270
}
266271

@@ -274,6 +279,10 @@ export default class MessagePanel extends React.Component<IProps, IState> {
274279
}
275280
}
276281

282+
private calculateRoomMembersCount = (): void => {
283+
this.membersCount = this.props.room?.getMembers().length || 0;
284+
};
285+
277286
private onShowTypingNotificationsChange = (): void => {
278287
this.setState({
279288
showTypingNotifications: SettingsStore.getValue("showTypingNotifications"),
@@ -711,7 +720,6 @@ export default class MessagePanel extends React.Component<IProps, IState> {
711720
isLastSuccessful = isLastSuccessful && mxEv.getSender() === MatrixClientPeg.get().getUserId();
712721

713722
const callEventGrouper = this.callEventGroupers.get(mxEv.getContent().call_id);
714-
715723
// use txnId as key if available so that we don't remount during sending
716724
ret.push(
717725
<TileErrorBoundary key={mxEv.getTxnId() || eventId} mxEvent={mxEv}>
@@ -743,7 +751,7 @@ export default class MessagePanel extends React.Component<IProps, IState> {
743751
enableFlair={this.props.enableFlair}
744752
showReadReceipts={this.props.showReadReceipts}
745753
callEventGrouper={callEventGrouper}
746-
hideSender={this.props.room?.getMembers().length <= 2 && this.props.layout === Layout.Bubble}
754+
hideSender={this.membersCount <= 2 && this.props.layout === Layout.Bubble}
747755
/>
748756
</TileErrorBoundary>,
749757
);

0 commit comments

Comments
 (0)