Fix:
* Chat should be displayed for waiting and ended lives * Chat and chat buttons must be cleaned out of the dom on navigation
This commit is contained in:
parent
db13377d81
commit
b071489e5b
@ -9,6 +9,8 @@
|
||||
### Fix
|
||||
|
||||
* Fix dom positionning
|
||||
* Chat should be displayed for waiting and ended lives
|
||||
* Chat and chat buttons must be cleaned out of the dom on navigation
|
||||
|
||||
## v0.0.5
|
||||
|
||||
|
16
client/common-client-plugin.js
Normal file
16
client/common-client-plugin.js
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
'use strict'
|
||||
|
||||
function register ({ registerHook, _peertubeHelpers }) {
|
||||
registerHook({
|
||||
target: 'action:router.navigation-end',
|
||||
handler: () => {
|
||||
document.querySelectorAll('.peertube-plugin-livechat-stuff')
|
||||
.forEach(dom => dom.remove())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export {
|
||||
register
|
||||
}
|
@ -44,7 +44,10 @@ function getIframeUri (uuid) {
|
||||
|
||||
function displayButton (buttons, name, label, callback) {
|
||||
const button = document.createElement('button')
|
||||
button.setAttribute('class', 'action-button peertube-plugin-livechat-button-' + name)
|
||||
button.setAttribute(
|
||||
'class',
|
||||
'action-button peertube-plugin-livechat-stuff peertube-plugin-livechat-button-' + name
|
||||
)
|
||||
button.setAttribute('type', 'button')
|
||||
button.textContent = label
|
||||
button.onclick = callback
|
||||
@ -108,13 +111,16 @@ function openChat () {
|
||||
|
||||
// Adding a class=row element
|
||||
const row = document.createElement('div')
|
||||
row.setAttribute('class', 'row peertube-plugin-livechat-stuff')
|
||||
row.setAttribute('class', 'row peertube-plugin-livechat-stuff peertube-plugin-livechat-iframe-stuff')
|
||||
videoWrapper.after(row)
|
||||
|
||||
// Creating the iframe...
|
||||
const iframe = document.createElement('iframe')
|
||||
iframe.setAttribute('src', iframeUri)
|
||||
iframe.setAttribute('class', 'peertube-plugin-livechat peertube-plugin-livechat-stuff')
|
||||
iframe.setAttribute(
|
||||
'class',
|
||||
'peertube-plugin-livechat peertube-plugin-livechat-stuff peertube-plugin-livechat-iframe-stuff'
|
||||
)
|
||||
iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts allow-popups allow-forms')
|
||||
iframe.setAttribute('frameborder', '0')
|
||||
if (additionalStyles) {
|
||||
@ -131,27 +137,21 @@ function openChat () {
|
||||
}
|
||||
|
||||
function closeChat () {
|
||||
document.querySelectorAll('.peertube-plugin-livechat-stuff')
|
||||
document.querySelectorAll('.peertube-plugin-livechat-iframe-stuff')
|
||||
.forEach(dom => dom.remove())
|
||||
|
||||
// showing/hiding buttons...
|
||||
toggleShowHideButtons(false)
|
||||
}
|
||||
|
||||
function register ({ registerHook, peertubeHelpers }) {
|
||||
registerHook({
|
||||
target: 'filter:api.video-watch.video.get.result',
|
||||
handler: (video) => {
|
||||
// For now, hooks for action:video-watch... did not receive the video object
|
||||
// So we store video objects in videoCache
|
||||
videoCache[video.uuid] = video
|
||||
lastUUID = video.uuid
|
||||
return video
|
||||
function initChat (peertubeHelpers) {
|
||||
if (document.querySelector('TODO')) {
|
||||
logger.log('The chat seems already initialized...')
|
||||
return
|
||||
}
|
||||
})
|
||||
registerHook({
|
||||
target: 'action:video-watch.video.loaded',
|
||||
handler: () => {
|
||||
// Adding a custom class in the dom, so we know initChat was already called.
|
||||
// TODO
|
||||
|
||||
peertubeHelpers.getSettings().then(s => {
|
||||
settings = s
|
||||
const liveOn = !!settings['chat-all-lives']
|
||||
@ -193,8 +193,30 @@ function register ({ registerHook, peertubeHelpers }) {
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function register ({ registerHook, peertubeHelpers }) {
|
||||
registerHook({
|
||||
target: 'filter:api.video-watch.video.get.result',
|
||||
handler: (video) => {
|
||||
// For now, hooks for action:video-watch... did not receive the video object
|
||||
// So we store video objects in videoCache
|
||||
videoCache[video.uuid] = video
|
||||
lastUUID = video.uuid
|
||||
// FIXME: this should be made in action:video-watch.video.loaded.
|
||||
// But with Peertube 3.0.1, this hook is not called for lives
|
||||
// in WAITING_FOR_LIVE and LIVE_ENDED states.
|
||||
initChat(peertubeHelpers)
|
||||
return video
|
||||
}
|
||||
})
|
||||
// FIXME: this should be the correct hook for initChat...
|
||||
// registerHook({
|
||||
// target: 'action:video-watch.video.loaded',
|
||||
// handler: () => {
|
||||
// initChat(peertubeHelpers)
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
export {
|
||||
|
@ -10,6 +10,12 @@
|
||||
"scopes": [
|
||||
"video-watch"
|
||||
]
|
||||
},
|
||||
{
|
||||
"script": "dist/common-client-plugin.js",
|
||||
"scopes": [
|
||||
"common"
|
||||
]
|
||||
}
|
||||
],
|
||||
"css": [
|
||||
|
@ -3,6 +3,7 @@ const path = require("path")
|
||||
const EsmWebpackPlugin = require("@purtuga/esm-webpack-plugin")
|
||||
|
||||
const clientFiles = [
|
||||
'common-client-plugin.js',
|
||||
'videowatch-client-plugin.js'
|
||||
]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user