From 4d6f14ab0bc7ed741c52f4f5f2983f78a6ef3dfa Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 25 Apr 2024 16:23:23 +0200 Subject: [PATCH] components/app: introduce updateDocumentTitle() The logic in here will get more involved once we add unread counts and such. --- components/app.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/components/app.js b/components/app.js index 488500e..21cd8e6 100644 --- a/components/app.js +++ b/components/app.js @@ -556,11 +556,7 @@ export default class App extends Component { this.whoChannelBuffer(buf.name, buf.server); } - if (buf.type !== BufferType.SERVER) { - document.title = buf.name + ' · ' + this.baseTitle; - } else { - document.title = this.baseTitle; - } + this.updateDocumentTitle(); }); // 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) { // Treat server-wide broadcasts as highlights. They're sent by server // operators and can contain important information.