From 992247201eec3343b2d5a54ef90b6695a32ccae6 Mon Sep 17 00:00:00 2001 From: dangwynne Date: Thu, 28 Jan 2021 20:36:33 +0000 Subject: [PATCH 1/2] Fix issue #16270 new rooms are titled 'Empty Room'. Signed-off-by: Dan Gwynne dangwynne1@gmail.com --- src/components/views/rooms/RoomTile.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/views/rooms/RoomTile.tsx b/src/components/views/rooms/RoomTile.tsx index c985e80010..631abeed10 100644 --- a/src/components/views/rooms/RoomTile.tsx +++ b/src/components/views/rooms/RoomTile.tsx @@ -110,6 +110,11 @@ export default class RoomTile extends React.PureComponent { CommunityPrototypeStore.getUpdateEventName(this.props.room.roomId), this.onCommunityUpdate, ); + this.props.room.on("Room.name", this.onRoomNameUpdate); + } + + private onRoomNameUpdate = (room) => { + this.forceUpdate(); } private onNotificationUpdate = () => { @@ -150,6 +155,8 @@ export default class RoomTile extends React.PureComponent { CommunityPrototypeStore.getUpdateEventName(this.props.room?.roomId), this.onCommunityUpdate, ); + prevProps.room.off("Room.name", this.onRoomNameUpdate); + this.props.room.on("Room.name", this.onRoomNameUpdate); } } @@ -171,6 +178,7 @@ export default class RoomTile extends React.PureComponent { CommunityPrototypeStore.getUpdateEventName(this.props.room.roomId), this.onCommunityUpdate, ); + this.props.room.off("Room.name", this.onRoomNameUpdate); } defaultDispatcher.unregister(this.dispatcherRef); this.notificationState.off(NOTIFICATION_STATE_UPDATE, this.onNotificationUpdate); From dc81496c3bcd9c0aa3cb1819c1e14daf822874c5 Mon Sep 17 00:00:00 2001 From: dangwynne Date: Fri, 29 Jan 2021 11:31:21 +0000 Subject: [PATCH 2/2] add optional chaining operator --- src/components/views/rooms/RoomTile.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/views/rooms/RoomTile.tsx b/src/components/views/rooms/RoomTile.tsx index 631abeed10..835447dc18 100644 --- a/src/components/views/rooms/RoomTile.tsx +++ b/src/components/views/rooms/RoomTile.tsx @@ -155,8 +155,8 @@ export default class RoomTile extends React.PureComponent { CommunityPrototypeStore.getUpdateEventName(this.props.room?.roomId), this.onCommunityUpdate, ); - prevProps.room.off("Room.name", this.onRoomNameUpdate); - this.props.room.on("Room.name", this.onRoomNameUpdate); + prevProps.room?.off("Room.name", this.onRoomNameUpdate); + this.props.room?.on("Room.name", this.onRoomNameUpdate); } }