From cdd2da90a9362a9e3b66d485a4431b9b55f164a0 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 22 Apr 2022 11:49:23 +0200 Subject: [PATCH] Update webpage title when switching buffer --- components/app.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/app.js b/components/app.js index f4f9dc9..3c1f2a6 100644 --- a/components/app.js +++ b/components/app.js @@ -196,6 +196,7 @@ export default class App extends Component { */ autoOpenURL = null; messageNotifications = new Set(); + baseTitle = null; constructor(props) { super(props); @@ -470,6 +471,12 @@ export default class App extends Component { if (buf.type === BufferType.NICK && !server.users.has(buf.name)) { this.whoUserBuffer(buf.name, buf.server); } + + if (buf.type !== BufferType.SERVER) { + document.title = buf.name + ' ยท ' + this.baseTitle; + } else { + document.title = this.baseTitle; + } }); } @@ -1666,9 +1673,14 @@ export default class App extends Component { } componentDidMount() { + this.baseTitle = document.title; setupKeybindings(this); } + componentWillUnmount() { + document.title = this.baseTitle; + } + render() { if (this.state.loading) { return html`
`;