From a1d5d83cc5c5c2f0af3a17e74bc584fa7f3cd8db Mon Sep 17 00:00:00 2001 From: John Livingston Date: Wed, 2 Jun 2021 12:20:15 +0200 Subject: [PATCH] Remove backward compatibility. --- assets/style.css | 1 - client/videowatch-client-plugin.ts | 38 ++++-------------------------- 2 files changed, 5 insertions(+), 34 deletions(-) diff --git a/assets/style.css b/assets/style.css index b0066666..6dd036c1 100644 --- a/assets/style.css +++ b/assets/style.css @@ -3,7 +3,6 @@ flex-direction: column; } -/* For Peertube >= 3.2.0 */ #plugin-placeholder-player-next #peertube-plugin-livechat-container { height: 100%; } diff --git a/client/videowatch-client-plugin.ts b/client/videowatch-client-plugin.ts index b77bad99..a4d6ebfc 100644 --- a/client/videowatch-client-plugin.ts +++ b/client/videowatch-client-plugin.ts @@ -1,11 +1,9 @@ import { videoHasWebchat } from 'shared/lib/video' -interface VideoCache {[key: string]: Video} - interface VideoWatchLoadedHookOptions { videojs: any - video?: Video // comes with Peertube 3.2.0 - playlist?: any // comes with Peertube 3.2.0 + video: Video + playlist?: any } function register ({ registerHook, peertubeHelpers }: RegisterOptions): void { @@ -16,10 +14,6 @@ function register ({ registerHook, peertubeHelpers }: RegisterOptions): void { warn: (s: string) => console.warn('[peertube-plugin-livechat] ' + s) } - // This is for backward compatibility with Peertube < 3.2.0. - const videoCache: VideoCache = {} - let lastUUID: string | null = null - let settings: any = {} function getBaseRoute (): string { @@ -178,10 +172,7 @@ function register ({ registerHook, peertubeHelpers }: RegisterOptions): void { logger.error('No video provided') return } - // Peertube >= 3.2.0 provide #plugin-placeholder-player-next - const placeholder = - document.getElementById('plugin-placeholder-player-next') ?? - document.getElementById('video-wrapper') + const placeholder = document.getElementById('plugin-placeholder-player-next') if (!placeholder) { logger.error('The required placeholder div is not present in the DOM.') return @@ -220,16 +211,6 @@ function register ({ registerHook, peertubeHelpers }: RegisterOptions): void { }) } - registerHook({ - target: 'filter:api.video-watch.video.get.result', - handler: (video: Video) => { - // For Peertube < 3.2.0, 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 - } - }) registerHook({ target: 'action:video-watch.video.loaded', handler: ({ @@ -237,17 +218,8 @@ function register ({ registerHook, peertubeHelpers }: RegisterOptions): void { playlist }: VideoWatchLoadedHookOptions) => { if (!video) { - logger.info('It seems we are using Peertube < 3.2.0. Using a cache to get the video object') - const uuid = lastUUID - if (!uuid) { - logger.error('There is no lastUUID.') - return - } - video = videoCache[uuid] - if (!video) { - logger.error('Can\'t find the video ' + uuid + ' in the videoCache') - return - } + logger.error('No video argument in hook action:video-watch.video.loaded') + return } if (playlist) { logger.info('We are in a playlist, we will not use the webchat')