Fix uncomplete commit.

This commit is contained in:
John Livingston 2021-02-20 16:03:44 +01:00
parent b27aa9e558
commit 767b9d0a27
4 changed files with 32 additions and 10 deletions

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## v0.0.7
### Bug Fixes
* Fix incomplete commit
## v0.0.6 ## v0.0.6
### Features ### Features

View File

@ -5,6 +5,11 @@ function register ({ registerHook, _peertubeHelpers }) {
registerHook({ registerHook({
target: 'action:router.navigation-end', target: 'action:router.navigation-end',
handler: () => { handler: () => {
const el = document.querySelector('.peertube-plugin-livechat-init')
if (el) {
el.classList.remove('peertube-plugin-livechat-init')
}
document.querySelectorAll('.peertube-plugin-livechat-stuff') document.querySelectorAll('.peertube-plugin-livechat-stuff')
.forEach(dom => dom.remove()) .forEach(dom => dom.remove())
} }

View File

@ -44,9 +44,10 @@ function getIframeUri (uuid) {
function displayButton (buttons, name, label, callback) { function displayButton (buttons, name, label, callback) {
const button = document.createElement('button') const button = document.createElement('button')
button.setAttribute( button.classList.add(
'class', 'action-button',
'action-button peertube-plugin-livechat-stuff peertube-plugin-livechat-button-' + name 'peertube-plugin-livechat-stuff',
'peertube-plugin-livechat-button-' + name
) )
button.setAttribute('type', 'button') button.setAttribute('type', 'button')
button.textContent = label button.textContent = label
@ -111,15 +112,20 @@ function openChat () {
// Adding a class=row element // Adding a class=row element
const row = document.createElement('div') const row = document.createElement('div')
row.setAttribute('class', 'row peertube-plugin-livechat-stuff peertube-plugin-livechat-iframe-stuff') row.classList.add(
'row',
'peertube-plugin-livechat-stuff',
'peertube-plugin-livechat-iframe-stuff'
)
videoWrapper.after(row) videoWrapper.after(row)
// Creating the iframe... // Creating the iframe...
const iframe = document.createElement('iframe') const iframe = document.createElement('iframe')
iframe.setAttribute('src', iframeUri) iframe.setAttribute('src', iframeUri)
iframe.setAttribute( iframe.classList.add(
'class', 'peertube-plugin-livechat',
'peertube-plugin-livechat peertube-plugin-livechat-stuff peertube-plugin-livechat-iframe-stuff' 'peertube-plugin-livechat-stuff',
'peertube-plugin-livechat-iframe-stuff'
) )
iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts allow-popups allow-forms') iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts allow-popups allow-forms')
iframe.setAttribute('frameborder', '0') iframe.setAttribute('frameborder', '0')
@ -145,12 +151,17 @@ function closeChat () {
} }
function initChat (peertubeHelpers) { function initChat (peertubeHelpers) {
if (document.querySelector('TODO')) { const el = document.querySelector('#videojs-wrapper')
if (!el) {
logger.error('The required div is not present in the DOM.')
return
}
if (el.classList.contains('peertube-plugin-livechat-init')) {
logger.log('The chat seems already initialized...') logger.log('The chat seems already initialized...')
return return
} }
// Adding a custom class in the dom, so we know initChat was already called. // Adding a custom class in the dom, so we know initChat was already called.
// TODO el.classList.add('peertube-plugin-livechat-init')
peertubeHelpers.getSettings().then(s => { peertubeHelpers.getSettings().then(s => {
settings = s settings = s

View File

@ -1,7 +1,7 @@
{ {
"name": "peertube-plugin-livechat", "name": "peertube-plugin-livechat",
"description": "PeerTube plugin livechat", "description": "PeerTube plugin livechat",
"version": "0.0.6", "version": "0.0.7",
"author": "John Livingston", "author": "John Livingston",
"bugs": "https://github.com/JohnXLivingston/peertube-plugin-livechat/issues", "bugs": "https://github.com/JohnXLivingston/peertube-plugin-livechat/issues",
"clientScripts": [ "clientScripts": [