Merge pull request #6916 from psrpinto/fix/settings-dialog-update-room-name
Update room settings dialog title when room name changes
This commit is contained in:
commit
1a1b178b5b
1 changed files with 21 additions and 2 deletions
|
@ -44,18 +44,31 @@ interface IProps {
|
||||||
initialTabId?: string;
|
initialTabId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IState {
|
||||||
|
roomName: string;
|
||||||
|
}
|
||||||
|
|
||||||
@replaceableComponent("views.dialogs.RoomSettingsDialog")
|
@replaceableComponent("views.dialogs.RoomSettingsDialog")
|
||||||
export default class RoomSettingsDialog extends React.Component<IProps> {
|
export default class RoomSettingsDialog extends React.Component<IProps, IState> {
|
||||||
private dispatcherRef: string;
|
private dispatcherRef: string;
|
||||||
|
|
||||||
|
constructor(props: IProps) {
|
||||||
|
super(props);
|
||||||
|
this.state = { roomName: '' };
|
||||||
|
}
|
||||||
|
|
||||||
public componentDidMount() {
|
public componentDidMount() {
|
||||||
this.dispatcherRef = dis.register(this.onAction);
|
this.dispatcherRef = dis.register(this.onAction);
|
||||||
|
MatrixClientPeg.get().on("Room.name", this.onRoomName);
|
||||||
|
this.onRoomName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentWillUnmount() {
|
public componentWillUnmount() {
|
||||||
if (this.dispatcherRef) {
|
if (this.dispatcherRef) {
|
||||||
dis.unregister(this.dispatcherRef);
|
dis.unregister(this.dispatcherRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MatrixClientPeg.get().removeListener("Room.name", this.onRoomName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onAction = (payload): void => {
|
private onAction = (payload): void => {
|
||||||
|
@ -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[] {
|
private getTabs(): Tab[] {
|
||||||
const tabs: Tab[] = [];
|
const tabs: Tab[] = [];
|
||||||
|
|
||||||
|
@ -122,7 +141,7 @@ export default class RoomSettingsDialog extends React.Component<IProps> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const roomName = MatrixClientPeg.get().getRoom(this.props.roomId).name;
|
const roomName = this.state.roomName;
|
||||||
return (
|
return (
|
||||||
<BaseDialog
|
<BaseDialog
|
||||||
className='mx_RoomSettingsDialog'
|
className='mx_RoomSettingsDialog'
|
||||||
|
|
Loading…
Reference in a new issue