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

Commit

Permalink
Merge pull request #6916 from psrpinto/fix/settings-dialog-update-roo…
Browse files Browse the repository at this point in the history
…m-name

Update room settings dialog title when room name changes
  • Loading branch information
turt2live committed Oct 7, 2021
2 parents 1b334e4 + 6aa325e commit 1a1b178
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/components/views/dialogs/RoomSettingsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,31 @@ interface IProps {
initialTabId?: string;
}

interface IState {
roomName: string;
}

@replaceableComponent("views.dialogs.RoomSettingsDialog")
export default class RoomSettingsDialog extends React.Component<IProps> {
export default class RoomSettingsDialog extends React.Component<IProps, IState> {
private dispatcherRef: string;

constructor(props: IProps) {
super(props);
this.state = { roomName: '' };
}

public componentDidMount() {
this.dispatcherRef = dis.register(this.onAction);
MatrixClientPeg.get().on("Room.name", this.onRoomName);
this.onRoomName();
}

public componentWillUnmount() {
if (this.dispatcherRef) {
dis.unregister(this.dispatcherRef);
}

MatrixClientPeg.get().removeListener("Room.name", this.onRoomName);
}

private onAction = (payload): void => {
Expand All @@ -66,6 +79,12 @@ export default class RoomSettingsDialog extends React.Component<IProps> {
}
};

private onRoomName = (): void => {
this.setState({
roomName: MatrixClientPeg.get().getRoom(this.props.roomId).name,
});
};

private getTabs(): Tab[] {
const tabs: Tab[] = [];

Expand Down Expand Up @@ -122,7 +141,7 @@ export default class RoomSettingsDialog extends React.Component<IProps> {
}

render() {
const roomName = MatrixClientPeg.get().getRoom(this.props.roomId).name;
const roomName = this.state.roomName;
return (
<BaseDialog
className='mx_RoomSettingsDialog'
Expand Down

0 comments on commit 1a1b178

Please sign in to comment.