aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-watch/video-watch.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-29 17:57:59 +0200
committerChocobozzz <me@florianbigard.com>2021-06-29 18:01:02 +0200
commit06a555797929d4867264b096c8420cdedd50f496 (patch)
treee68b0038d3f3f8ccae43b3bd22509200888a699a /client/src/app/+videos/+video-watch/video-watch.component.ts
parent6ebdd12f8806edd7076e89c8ea3bcfaf5658b2b6 (diff)
downloadPeerTube-06a555797929d4867264b096c8420cdedd50f496.tar.gz
PeerTube-06a555797929d4867264b096c8420cdedd50f496.tar.zst
PeerTube-06a555797929d4867264b096c8420cdedd50f496.zip
Move watch action buttons in a dedicated component
Diffstat (limited to 'client/src/app/+videos/+video-watch/video-watch.component.ts')
-rw-r--r--client/src/app/+videos/+video-watch/video-watch.component.ts56
1 files changed, 6 insertions, 50 deletions
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 5a0109e64..ca20c2b85 100644
--- a/client/src/app/+videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/+videos/+video-watch/video-watch.component.ts
@@ -18,24 +18,13 @@ import {
18 UserService 18 UserService
19} from '@app/core' 19} from '@app/core'
20import { HooksService } from '@app/core/plugins/hooks.service' 20import { HooksService } from '@app/core/plugins/hooks.service'
21import { RedirectService } from '@app/core/routing/redirect.service'
22import { isXPercentInViewport, scrollToTop } from '@app/helpers' 21import { isXPercentInViewport, scrollToTop } from '@app/helpers'
23import { Video, VideoCaptionService, VideoDetails, VideoService } from '@app/shared/shared-main' 22import { Video, VideoCaptionService, VideoDetails, VideoService } from '@app/shared/shared-main'
24import { VideoShareComponent } from '@app/shared/shared-share-modal'
25import { SupportModalComponent } from '@app/shared/shared-support-modal'
26import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription' 23import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription'
27import { VideoActionsDisplayType, VideoDownloadComponent } from '@app/shared/shared-video-miniature' 24import { VideoActionsDisplayType } from '@app/shared/shared-video-miniature'
28import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' 25import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
29import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 26import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
30import { 27import { HTMLServerConfig, PeerTubeProblemDocument, ServerErrorCode, VideoCaption, VideoPrivacy, VideoState } from '@shared/models'
31 HTMLServerConfig,
32 PeerTubeProblemDocument,
33 ServerErrorCode,
34 UserVideoRateType,
35 VideoCaption,
36 VideoPrivacy,
37 VideoState
38} from '@shared/models'
39import { cleanupVideoWatch, getStoredTheater, getStoredVideoWatchHistory } from '../../../assets/player/peertube-player-local-storage' 28import { cleanupVideoWatch, getStoredTheater, getStoredVideoWatchHistory } from '../../../assets/player/peertube-player-local-storage'
40import { 29import {
41 CustomizationOptions, 30 CustomizationOptions,
@@ -58,10 +47,7 @@ type URLOptions = CustomizationOptions & { playerMode: PlayerMode }
58}) 47})
59export class VideoWatchComponent implements OnInit, OnDestroy { 48export class VideoWatchComponent implements OnInit, OnDestroy {
60 @ViewChild('videoWatchPlaylist', { static: true }) videoWatchPlaylist: VideoWatchPlaylistComponent 49 @ViewChild('videoWatchPlaylist', { static: true }) videoWatchPlaylist: VideoWatchPlaylistComponent
61 @ViewChild('videoShareModal') videoShareModal: VideoShareComponent
62 @ViewChild('supportModal') supportModal: SupportModalComponent
63 @ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent 50 @ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent
64 @ViewChild('videoDownloadModal') videoDownloadModal: VideoDownloadComponent
65 51
66 player: any 52 player: any
67 playerElement: HTMLVideoElement 53 playerElement: HTMLVideoElement
@@ -95,8 +81,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
95 liveInfo: true 81 liveInfo: true
96 } 82 }
97 83
98 userRating: UserVideoRateType
99
100 private nextVideoUuid = '' 84 private nextVideoUuid = ''
101 private nextVideoTitle = '' 85 private nextVideoTitle = ''
102 private currentTime: number 86 private currentTime: number
@@ -124,7 +108,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
124 private restExtractor: RestExtractor, 108 private restExtractor: RestExtractor,
125 private notifier: Notifier, 109 private notifier: Notifier,
126 private zone: NgZone, 110 private zone: NgZone,
127 private redirectService: RedirectService,
128 private videoCaptionService: VideoCaptionService, 111 private videoCaptionService: VideoCaptionService,
129 private hotkeysService: HotkeysService, 112 private hotkeysService: HotkeysService,
130 private hooks: HooksService, 113 private hooks: HooksService,
@@ -203,20 +186,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
203 this.hotkeysService.remove(this.hotkeys) 186 this.hotkeysService.remove(this.hotkeys)
204 } 187 }
205 188
206 showDownloadModal () { 189 getCurrentTime () {
207 this.videoDownloadModal.show(this.video, this.videoCaptions) 190 return this.currentTime
208 }
209
210 isVideoDownloadable () {
211 return this.video && this.video instanceof VideoDetails && this.video.downloadEnabled && !this.video.isLive
212 } 191 }
213 192
214 showSupportModal () { 193 getCurrentPlaylistPosition () {
215 this.supportModal.show() 194 return this.videoWatchPlaylist.currentPlaylistPosition
216 }
217
218 showShareModal () {
219 this.videoShareModal.show(this.currentTime, this.videoWatchPlaylist.currentPlaylistPosition)
220 } 195 }
221 196
222 isUserLoggedIn () { 197 isUserLoggedIn () {
@@ -245,10 +220,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
245 } 220 }
246 } 221 }
247 222
248 onVideoRemoved () {
249 this.redirectService.redirectToHomepage()
250 }
251
252 isVideoToTranscode () { 223 isVideoToTranscode () {
253 return this.video && this.video.state.id === VideoState.TO_TRANSCODE 224 return this.video && this.video.state.id === VideoState.TO_TRANSCODE
254 } 225 }
@@ -261,10 +232,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
261 return this.video && this.video.scheduledUpdate !== undefined 232 return this.video && this.video.scheduledUpdate !== undefined
262 } 233 }
263 234
264 isLive () {
265 return !!(this.video?.isLive)
266 }
267
268 isWaitingForLive () { 235 isWaitingForLive () {
269 return this.video?.state.id === VideoState.WAITING_FOR_LIVE 236 return this.video?.state.id === VideoState.WAITING_FOR_LIVE
270 } 237 }
@@ -311,11 +278,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
311 this.loadVideo(videoId) 278 this.loadVideo(videoId)
312 } 279 }
313 280
314 onRateUpdated (userRating: UserVideoRateType) {
315 this.userRating = userRating
316 this.setVideoLikesBarTooltipText()
317 }
318
319 displayOtherVideosAsRow () { 281 displayOtherVideosAsRow () {
320 // Use the same value as in the SASS file 282 // Use the same value as in the SASS file
321 return this.screenService.getWindowInnerWidth() <= 1100 283 return this.screenService.getWindowInnerWidth() <= 1100
@@ -421,10 +383,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
421 }) 383 })
422 } 384 }
423 385
424 private setVideoLikesBarTooltipText () {
425 this.likesBarTooltipText = `${this.video.likes} likes / ${this.video.dislikes} dislikes`
426 }
427
428 private handleError (err: any) { 386 private handleError (err: any) {
429 const errorMessage: string = typeof err === 'string' ? err : err.message 387 const errorMessage: string = typeof err === 'string' ? err : err.message
430 if (!errorMessage) return 388 if (!errorMessage) return
@@ -467,8 +425,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
467 this.buildPlayer(urlOptions) 425 this.buildPlayer(urlOptions)
468 .catch(err => console.error('Cannot build the player', err)) 426 .catch(err => console.error('Cannot build the player', err))
469 427
470 this.setVideoLikesBarTooltipText()
471
472 this.setOpenGraphTags() 428 this.setOpenGraphTags()
473 429
474 const hookOptions = { 430 const hookOptions = {