Merge pull request #3471 from matrix-org/matthew/room_name

put the room name in the title tag
pull/21833/head
Matthew Hodgson 2019-09-23 22:19:09 +01:00 committed by GitHub
commit 76d691c373
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 5 deletions

View File

@ -271,6 +271,10 @@ export default createReactClass({
this.focusComposer = false;
// object field used for tracking the status info appended to the title tag.
// we don't do it as react state as i'm scared about triggering needless react refreshes.
this.subTitleStatus = '';
// this can technically be done anywhere but doing this here keeps all
// the routing url path logic together.
if (this.onAliasClick) {
@ -1297,6 +1301,7 @@ export default createReactClass({
collapsedRhs: false,
currentRoomId: null,
});
this.subTitleStatus = '';
this._setPageSubtitle();
},
@ -1312,6 +1317,7 @@ export default createReactClass({
collapsedRhs: false,
currentRoomId: null,
});
this.subTitleStatus = '';
this._setPageSubtitle();
},
@ -1706,6 +1712,7 @@ export default createReactClass({
if (this.props.onNewScreen) {
this.props.onNewScreen(screen);
}
this._setPageSubtitle();
},
onAliasClick: function(event, alias) {
@ -1821,7 +1828,13 @@ export default createReactClass({
},
_setPageSubtitle: function(subtitle='') {
document.title = `${SdkConfig.get().brand || 'Riot'} ${subtitle}`;
if (this.state.currentRoomId) {
const room = MatrixClientPeg.get().getRoom(this.state.currentRoomId);
if (room) {
subtitle = `| ${ room.name }`;
}
}
document.title = `${SdkConfig.get().brand || 'Riot'} ${subtitle} ${this.subTitleStatus}`;
},
updateStatusIndicator: function(state, prevState) {
@ -1832,15 +1845,15 @@ export default createReactClass({
PlatformPeg.get().setNotificationCount(notifCount);
}
let subtitle = '';
this.subTitleStatus = '';
if (state === "ERROR") {
subtitle += `[${_t("Offline")}] `;
this.subTitleStatus += `[${_t("Offline")}] `;
}
if (notifCount > 0) {
subtitle += `[${notifCount}]`;
this.subTitleStatus += `[${notifCount}]`;
}
this._setPageSubtitle(subtitle);
this._setPageSubtitle();
},
onCloseAllSettings() {