Chat can be enabled in video properties.

This commit is contained in:
John Livingston
2021-06-08 18:08:58 +02:00
parent 07b7f4d732
commit 385a0074c1
11 changed files with 154 additions and 16 deletions

View File

@ -1,5 +1,5 @@
function register ({ registerHook }: RegisterOptions): void {
async function register ({ peertubeHelpers, registerHook, registerVideoField }: RegisterOptions): Promise<void> {
registerHook({
target: 'action:router.navigation-end',
handler: () => {
@ -9,6 +9,34 @@ function register ({ registerHook }: RegisterOptions): void {
}
}
})
const [label, description, settings] = await Promise.all([
peertubeHelpers.translate('Use chat'),
peertubeHelpers.translate('If enabled, there will be a chat next to the video.'),
peertubeHelpers.getSettings()
])
const webchatFieldOptions: RegisterClientFormFieldOptions = {
name: 'livechat-active',
label: label,
descriptionHTML: description,
type: 'input-checkbox',
default: true,
hidden: ({ liveVideo }) => {
if (!liveVideo) {
return true
}
if (!settings['chat-per-live-video']) {
return true
}
if (settings['chat-all-lives']) {
// No need to add this field if live is active for all live videos
return true
}
return false
}
}
registerVideoField(webchatFieldOptions, { type: 'update' })
registerVideoField(webchatFieldOptions, { type: 'go-live' })
}
export {