From 767b9d0a27cf01c8af68daaeedb32f6d9c66f192 Mon Sep 17 00:00:00 2001 From: John Livingston Date: Sat, 20 Feb 2021 16:03:44 +0100 Subject: [PATCH] Fix uncomplete commit. --- CHANGELOG.md | 6 ++++++ client/common-client-plugin.js | 5 +++++ client/videowatch-client-plugin.js | 29 ++++++++++++++++++++--------- package.json | 2 +- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2493e17d..80963c6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v0.0.7 + +### Bug Fixes + +* Fix incomplete commit + ## v0.0.6 ### Features diff --git a/client/common-client-plugin.js b/client/common-client-plugin.js index 31f9b3fb..dde51eaa 100644 --- a/client/common-client-plugin.js +++ b/client/common-client-plugin.js @@ -5,6 +5,11 @@ function register ({ registerHook, _peertubeHelpers }) { registerHook({ target: 'action:router.navigation-end', handler: () => { + const el = document.querySelector('.peertube-plugin-livechat-init') + if (el) { + el.classList.remove('peertube-plugin-livechat-init') + } + document.querySelectorAll('.peertube-plugin-livechat-stuff') .forEach(dom => dom.remove()) } diff --git a/client/videowatch-client-plugin.js b/client/videowatch-client-plugin.js index 66d40fae..cc904e35 100644 --- a/client/videowatch-client-plugin.js +++ b/client/videowatch-client-plugin.js @@ -44,9 +44,10 @@ function getIframeUri (uuid) { function displayButton (buttons, name, label, callback) { const button = document.createElement('button') - button.setAttribute( - 'class', - 'action-button peertube-plugin-livechat-stuff peertube-plugin-livechat-button-' + name + button.classList.add( + 'action-button', + 'peertube-plugin-livechat-stuff', + 'peertube-plugin-livechat-button-' + name ) button.setAttribute('type', 'button') button.textContent = label @@ -111,15 +112,20 @@ function openChat () { // Adding a class=row element 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) // Creating the iframe... const iframe = document.createElement('iframe') iframe.setAttribute('src', iframeUri) - iframe.setAttribute( - 'class', - 'peertube-plugin-livechat peertube-plugin-livechat-stuff peertube-plugin-livechat-iframe-stuff' + iframe.classList.add( + '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') @@ -145,12 +151,17 @@ function closeChat () { } 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...') return } // 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 => { settings = s diff --git a/package.json b/package.json index 398bed2d..bf5f23d4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "peertube-plugin-livechat", "description": "PeerTube plugin livechat", - "version": "0.0.6", + "version": "0.0.7", "author": "John Livingston", "bugs": "https://github.com/JohnXLivingston/peertube-plugin-livechat/issues", "clientScripts": [