put the room name in the title tag

should fix https://github.com/vector-im/riot-web/issues/4454
pull/21833/head
Matthew Hodgson 2019-09-23 22:01:49 +01:00
parent 4933b9b050
commit 54355c0e28
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() {