aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-12 17:16:48 +0100
committerChocobozzz <me@florianbigard.com>2018-01-12 17:17:45 +0100
commit339632b4a3f94a6ebee3767054ef6c701858a785 (patch)
treee71fe304d9b4b732609724ee2402be97843d2332 /client/src
parent0af3182bf77aac7fc0a122d559ccb1941e75db23 (diff)
downloadPeerTube-339632b4a3f94a6ebee3767054ef6c701858a785.tar.gz
PeerTube-339632b4a3f94a6ebee3767054ef6c701858a785.tar.zst
PeerTube-339632b4a3f94a6ebee3767054ef6c701858a785.zip
Fix changing video in watch page
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comments.component.ts27
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.ts2
-rw-r--r--client/src/assets/player/peertube-videojs-plugin.ts20
3 files changed, 34 insertions, 15 deletions
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts
index 030dee9af..6025256de 100644
--- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts
@@ -1,4 +1,4 @@
1import { Component, Input, OnInit } from '@angular/core' 1import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'
2import { ConfirmService } from '@app/core' 2import { ConfirmService } from '@app/core'
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4import { VideoComment as VideoCommentInterface, VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' 4import { VideoComment as VideoCommentInterface, VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model'
@@ -15,7 +15,7 @@ import { VideoCommentService } from './video-comment.service'
15 templateUrl: './video-comments.component.html', 15 templateUrl: './video-comments.component.html',
16 styleUrls: ['./video-comments.component.scss'] 16 styleUrls: ['./video-comments.component.scss']
17}) 17})
18export class VideoCommentsComponent implements OnInit { 18export class VideoCommentsComponent implements OnChanges {
19 @Input() video: VideoDetails 19 @Input() video: VideoDetails
20 @Input() user: User 20 @Input() user: User
21 21
@@ -37,9 +37,9 @@ export class VideoCommentsComponent implements OnInit {
37 private videoCommentService: VideoCommentService 37 private videoCommentService: VideoCommentService
38 ) {} 38 ) {}
39 39
40 ngOnInit () { 40 ngOnChanges (changes: SimpleChanges) {
41 if (this.video.commentsEnabled === true) { 41 if (changes['video']) {
42 this.loadMoreComments() 42 this.loadVideoComments()
43 } 43 }
44 } 44 }
45 45
@@ -152,4 +152,21 @@ export class VideoCommentsComponent implements OnInit {
152 this.deleteLocalCommentThread(commentChild, commentToDelete) 152 this.deleteLocalCommentThread(commentChild, commentToDelete)
153 } 153 }
154 } 154 }
155
156 private loadVideoComments () {
157 if (this.video.commentsEnabled === true) {
158 // Reset all our fields
159 this.comments = []
160 this.threadComments = {}
161 this.threadLoading = {}
162 this.inReplyToCommentId = undefined
163 this.componentPagination = {
164 currentPage: 1,
165 itemsPerPage: 10,
166 totalItems: null
167 }
168
169 this.loadMoreComments()
170 }
171 }
155} 172}
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts
index 1c2317c52..c9bdd4dfc 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/videos/+video-watch/video-watch.component.ts
@@ -347,7 +347,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
347 }) 347 })
348 }) 348 })
349 } else { 349 } else {
350 (this.player as any).setVideoFiles(this.video.files) 350 this.player.peertube().setVideoFiles(this.video.files)
351 } 351 }
352 352
353 this.setVideoDescriptionHTML() 353 this.setVideoDescriptionHTML()
diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts
index 34c993f3c..0a7651a81 100644
--- a/client/src/assets/player/peertube-videojs-plugin.ts
+++ b/client/src/assets/player/peertube-videojs-plugin.ts
@@ -5,18 +5,20 @@ import * as WebTorrent from 'webtorrent'
5import { VideoFile } from '../../../../shared/models/videos/video.model' 5import { VideoFile } from '../../../../shared/models/videos/video.model'
6import { renderVideo } from './video-renderer' 6import { renderVideo } from './video-renderer'
7 7
8declare module 'video.js' {
9 interface Player {
10 peertube (): PeerTubePlugin
11 }
12}
13
8interface VideoJSComponentInterface { 14interface VideoJSComponentInterface {
9 _player: VideoJSPlayer 15 _player: videojs.Player
10 16
11 new (player: VideoJSPlayer, options?: any) 17 new (player: videojs.Player, options?: any)
12 18
13 registerComponent (name: string, obj: any) 19 registerComponent (name: string, obj: any)
14} 20}
15 21
16interface VideoJSPlayer extends videojs.Player {
17 peertube (): PeerTubePlugin
18}
19
20type PeertubePluginOptions = { 22type PeertubePluginOptions = {
21 videoFiles: VideoFile[] 23 videoFiles: VideoFile[]
22 playerElement: HTMLVideoElement 24 playerElement: HTMLVideoElement
@@ -45,7 +47,7 @@ const webtorrent = new WebTorrent({ dht: false })
45const MenuItem: VideoJSComponentInterface = videojsUntyped.getComponent('MenuItem') 47const MenuItem: VideoJSComponentInterface = videojsUntyped.getComponent('MenuItem')
46class ResolutionMenuItem extends MenuItem { 48class ResolutionMenuItem extends MenuItem {
47 49
48 constructor (player: VideoJSPlayer, options) { 50 constructor (player: videojs.Player, options) {
49 options.selectable = true 51 options.selectable = true
50 super(player, options) 52 super(player, options)
51 53
@@ -64,7 +66,7 @@ const MenuButton: VideoJSComponentInterface = videojsUntyped.getComponent('MenuB
64class ResolutionMenuButton extends MenuButton { 66class ResolutionMenuButton extends MenuButton {
65 label: HTMLElement 67 label: HTMLElement
66 68
67 constructor (player: VideoJSPlayer, options) { 69 constructor (player: videojs.Player, options) {
68 options.label = 'Quality' 70 options.label = 'Quality'
69 super(player, options) 71 super(player, options)
70 72
@@ -215,7 +217,7 @@ class PeerTubePlugin extends Plugin {
215 private videoFiles: VideoFile[] 217 private videoFiles: VideoFile[]
216 private torrent: WebTorrent.Torrent 218 private torrent: WebTorrent.Torrent
217 219
218 constructor (player: VideoJSPlayer, options: PeertubePluginOptions) { 220 constructor (player: videojs.Player, options: PeertubePluginOptions) {
219 super(player, options) 221 super(player, options)
220 222
221 this.videoFiles = options.videoFiles 223 this.videoFiles = options.videoFiles