diff --git a/CHANGELOG.md b/CHANGELOG.md index 38ff2741..263c33b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,12 @@ * Fix spanish translation. +## v5.0.2 + +### Fixes + +* Fix some cases where the chat immediatly close (Peertube events are not fired in the good order). + ## v5.0.1 ### Breaking changes diff --git a/client/common-client-plugin.ts b/client/common-client-plugin.ts index e5c40d82..6bee6279 100644 --- a/client/common-client-plugin.ts +++ b/client/common-client-plugin.ts @@ -5,6 +5,15 @@ async function register ({ peertubeHelpers, registerHook, registerVideoField }: handler: () => { const container = document.querySelector('#peertube-plugin-livechat-container') if (container) { + const url = container.getAttribute('peertube-plugin-livechat-current-url') + if (url && url === window.location.href) { + console.warn( + '[peertube-plugin-livechat navigation-end] ' + + 'It seems that action:router.navigation-end was called after action:video-watch.video.loaded. ' + + 'No removing the chat from the DOM.' + ) + return + } container.remove() } } diff --git a/client/videowatch-client-plugin.ts b/client/videowatch-client-plugin.ts index ef888934..db017173 100644 --- a/client/videowatch-client-plugin.ts +++ b/client/videowatch-client-plugin.ts @@ -289,6 +289,7 @@ function register ({ registerHook, peertubeHelpers }: RegisterOptions): void { container = document.createElement('div') container.setAttribute('id', 'peertube-plugin-livechat-container') container.setAttribute('peertube-plugin-livechat-state', 'initializing') + container.setAttribute('peertube-plugin-livechat-current-url', window.location.href) placeholder.append(container) peertubeHelpers.getSettings().then((s: any) => { diff --git a/package-lock.json b/package-lock.json index c26928c2..1a12b932 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "peertube-plugin-livechat", - "version": "5.0.1", + "version": "5.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 198ead6a..bcdec751 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "peertube-plugin-livechat", "description": "PeerTube plugin livechat: offers a way to embed a chat system into Peertube.", - "version": "5.0.1", + "version": "5.0.2", "author": { "name": "John Livingston", "url": "https://github.com/JohnXLivingston"