WIP new full screen chat

This commit is contained in:
John Livingston 2023-12-27 15:51:43 +01:00
parent bd695bdb27
commit 22a675e915
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
3 changed files with 22 additions and 5 deletions

View File

@ -169,3 +169,11 @@ table.peertube-plugin-livechat-prosody-list-rooms td {
min-height: 60px;
}
}
.livechat-embed-fullpage {
converse-root {
display: block;
height: 90vh;
min-height: 400px;
}
}

View File

@ -39,11 +39,15 @@ async function registerConfiguration (clientOptions: RegisterClientOptions): Pro
const converseJSParams: InitConverseJSParams = await (response).json()
await loadConverseJS(converseJSParams)
rootEl.innerHTML = `<div class="converse-fullscreen theme-peertube">
<div id="conversejs-bg" class="theme-peertube">
</div>`
const container = document.createElement('div')
container.classList.add('margin-content')
container.classList.add('livechat-embed-fullpage')
rootEl.append(container)
const converseRoot = document.createElement('converse-root')
converseRoot.classList.add('theme-peertube')
container.append(converseRoot)
window.initConverse(converseJSParams)
window.initConverse(converseJSParams, 'embedded')
} catch (err) {
console.error('[peertube-plugin-livechat] ' + (err as string))
rootEl.innerText = await peertubeHelpers.translate(LOC_NOT_FOUND)

View File

@ -24,7 +24,10 @@ declare global {
}
}
window.initConverse = async function initConverse (initConverseParams: InitConverseJSParams): Promise<void> {
window.initConverse = async function initConverse (
initConverseParams: InitConverseJSParams,
viewMode: 'fullscreen' | 'embedded' = 'fullscreen'
): Promise<void> {
// First, fixing relative websocket urls.
if (initConverseParams.localWebsocketServiceUrl?.startsWith('/')) {
initConverseParams.localWebsocketServiceUrl = new URL(
@ -47,6 +50,8 @@ window.initConverse = async function initConverse (initConverseParams: InitConve
const isInIframe = inIframe()
initDom(initConverseParams, isInIframe)
const params = defaultConverseParams(initConverseParams, isInIframe)
params.view_mode = viewMode
params.allow_url_history_change = viewMode === 'fullscreen'
let isAuthenticated: boolean = false
let isRemoteWithNicknameSet: boolean = false