ConverseJS: document title set to the room name.
This commit is contained in:
parent
8f12ca0c45
commit
7f6a2cd7ee
@ -2,6 +2,9 @@
|
||||
interface Window {
|
||||
converse: {
|
||||
initialize: (args: any) => void
|
||||
plugins: {
|
||||
add: (name: string, plugin: any) => void
|
||||
}
|
||||
}
|
||||
initConverse: (args: any) => void
|
||||
}
|
||||
@ -141,7 +144,8 @@ window.initConverse = async function initConverse ({
|
||||
},
|
||||
theme: theme || 'peertube',
|
||||
persistent_store: 'sessionStorage',
|
||||
show_images_inline: false // for security reason, and to avoid bugs when image is larger that iframe
|
||||
show_images_inline: false, // for security reason, and to avoid bugs when image is larger that iframe
|
||||
whitelisted_plugins: ['livechatWindowTitlePlugin']
|
||||
}
|
||||
|
||||
// TODO: params.clear_messages_on_reconnection = true when muc_mam will be available.
|
||||
@ -191,6 +195,25 @@ window.initConverse = async function initConverse ({
|
||||
}
|
||||
|
||||
try {
|
||||
window.converse.plugins.add('livechatWindowTitlePlugin', {
|
||||
dependencies: ['converse-muc-views'],
|
||||
overrides: {
|
||||
ChatRoomView: {
|
||||
renderHeading: function (this: any): any {
|
||||
console.log('[livechatWindowTitlePlugin] updating the document title.')
|
||||
try {
|
||||
const title = this.model.getDisplayName()
|
||||
if (document.title !== title) {
|
||||
document.title = title
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed updating the window title', err)
|
||||
}
|
||||
return this.__super__.renderHeading.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
window.converse.initialize(params)
|
||||
} catch (error) {
|
||||
console.error('Failed initializing converseJS', error)
|
||||
|
@ -1,10 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="no-js">
|
||||
<head>
|
||||
<title>Converse</title>
|
||||
<title>Peertube LiveChat Plugin</title>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<meta name="description" content="Converse XMPP/Jabber Chat"/>
|
||||
<meta name="description" content="Peertube LiveChat Plugin"/>
|
||||
<link type="text/css" rel="stylesheet" media="screen" href="{{BASE_STATIC_URL}}conversejs/converse.min.css" />
|
||||
<script type="text/javaScript" src="{{BASE_STATIC_URL}}conversejs/converse.min.js"></script>
|
||||
<script type="text/javascript" src="{{BASE_STATIC_URL}}static/builtin.js"></script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user