peertube-plugin-livechat/conversejs/lib/plugins/window-title.ts
John Livingston 8988a85ec9
Refactoring + new embedded chat:
* moving conversejs plugin in separate files
* disconnecting embedded chat on navigation-end
2024-03-27 16:26:32 +01:00

22 lines
661 B
TypeScript

export const windowTitlePlugin = {
dependencies: ['converse-muc-views'],
overrides: {
ChatRoomView: {
requestUpdate: function (this: any): any {
console.log('[livechatWindowTitlePlugin] updating the document title.')
try {
if (this.model?.getDisplayName) {
const title = this.model.getDisplayName()
if (document.title !== title) {
document.title = title
}
}
} catch (err) {
console.error('[livechatWindowTitlePlugin] Failed updating the window title', err)
}
return this.__super__.requestUpdate.apply(this)
}
}
}
}