components/app: introduce updateDocumentTitle()

The logic in here will get more involved once we add unread counts
and such.
This commit is contained in:
Simon Ser 2024-04-25 16:23:23 +02:00
parent 9924f08794
commit 4d6f14ab0b

View file

@ -556,11 +556,7 @@ export default class App extends Component {
this.whoChannelBuffer(buf.name, buf.server); this.whoChannelBuffer(buf.name, buf.server);
} }
if (buf.type !== BufferType.SERVER) { this.updateDocumentTitle();
document.title = buf.name + ' · ' + this.baseTitle;
} else {
document.title = this.baseTitle;
}
}); });
// TODO: only mark as read if user scrolled at the bottom // TODO: only mark as read if user scrolled at the bottom
@ -610,6 +606,15 @@ export default class App extends Component {
}); });
} }
updateDocumentTitle() {
let buf = State.getBuffer(this.state, this.state.activeBuffer);
if (buf && buf.type !== BufferType.SERVER) {
document.title = buf.name + ' · ' + this.baseTitle;
} else {
document.title = this.baseTitle;
}
}
prepareChatMessage(serverID, msg) { prepareChatMessage(serverID, msg) {
// Treat server-wide broadcasts as highlights. They're sent by server // Treat server-wide broadcasts as highlights. They're sent by server
// operators and can contain important information. // operators and can contain important information.