Remove backward compatibility.

This commit is contained in:
John Livingston 2021-06-02 12:20:15 +02:00
parent a761d7067e
commit a1d5d83cc5
2 changed files with 5 additions and 34 deletions

View File

@ -3,7 +3,6 @@
flex-direction: column;
}
/* For Peertube >= 3.2.0 */
#plugin-placeholder-player-next #peertube-plugin-livechat-container {
height: 100%;
}

View File

@ -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')