Room list: using new chat page

This commit is contained in:
John Livingston
2024-04-03 12:13:44 +02:00
parent 624f053d02
commit e5e6c6f953
7 changed files with 55 additions and 33 deletions

View File

@ -1,7 +1,6 @@
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
import { renderConfigurationHome } from './templates/home'
import { renderConfigurationChannel } from './templates/channel'
import { displayConverseJS } from '../../utils/conversejs'
/**
* Registers stuff related to the user's configuration pages.
@ -13,29 +12,6 @@ async function registerConfiguration (clientOptions: RegisterClientOptions): Pro
const settings = await peertubeHelpers.getSettings()
if (settings['disable-channel-configuration']) { return }
registerClientRoute({
route: 'livechat/room',
onMount: async ({ rootEl }) => {
try {
const urlParams = new URLSearchParams(window.location.search)
const roomKey = urlParams.get('room')
if (!roomKey) {
throw new Error('missing room parameter')
}
const container = document.createElement('div')
container.classList.add('livechat-embed-fullpage')
rootEl.append(container)
await displayConverseJS(clientOptions, container, roomKey, 'peertube-fullpage')
} catch (err) {
console.error('[peertube-plugin-livechat] ' + (err as string))
// FIXME: do a better error page.
rootEl.innerText = await peertubeHelpers.translate(LOC_NOT_FOUND)
}
}
})
registerClientRoute({
route: 'livechat/configuration',
onMount: async ({ rootEl }) => {

View File

@ -0,0 +1,38 @@
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
import { displayConverseJS } from '../../utils/conversejs'
/**
* Registers stuff related to "room" page.
* @param clientOptions Peertube client options
*/
async function registerRoom (clientOptions: RegisterClientOptions): Promise<void> {
const { peertubeHelpers, registerClientRoute } = clientOptions
registerClientRoute({
route: 'livechat/room',
onMount: async ({ rootEl }) => {
try {
const urlParams = new URLSearchParams(window.location.search)
const roomKey = urlParams.get('room')
if (!roomKey) {
throw new Error('missing room parameter')
}
const forceType = urlParams.get('forcetype') === '1'
const container = document.createElement('div')
container.classList.add('livechat-embed-fullpage')
rootEl.append(container)
await displayConverseJS(clientOptions, container, roomKey, 'peertube-fullpage', forceType)
} catch (err) {
console.error('[peertube-plugin-livechat] ' + (err as string))
// FIXME: do a better error page.
rootEl.innerText = await peertubeHelpers.translate(LOC_NOT_FOUND)
}
}
})
}
export {
registerRoom
}