Fix #48: Proper 404 and 403 pages when trying to open non-existant chatroom (WIP).

This commit is contained in:
John Livingston
2024-04-04 10:58:16 +02:00
parent 972306aa3e
commit 0719d25f35
12 changed files with 198 additions and 104 deletions

View File

@ -214,7 +214,15 @@ function register (registerOptions: RegisterClientOptions): void {
// Loading converseJS...
await displayConverseJS(registerOptions, container, roomkey, 'peertube-video', false)
} catch (err) {
// Displaying an error page.
if (container) {
const message = document.createElement('div')
message.classList.add('peertube-plugin-livechat-error-message')
message.innerText = await peertubeHelpers.translate(LOC_CHATROOM_NOT_ACCESSIBLE)
container.append(message)
}
hackStyles(false)
}
}
@ -229,7 +237,9 @@ function register (registerOptions: RegisterClientOptions): void {
if (window.converse?.livechatDisconnect) { window.converse.livechatDisconnect() }
// Removing from the DOM
container.querySelectorAll('converse-root, .livechat-spinner').forEach(dom => dom.remove())
container.querySelectorAll(
'converse-root, .livechat-spinner, .peertube-plugin-livechat-error-message'
).forEach(dom => dom.remove())
container.setAttribute('peertube-plugin-livechat-state', 'closed')