aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/shared/video-playlist/video-add-to-playlist.component.ts26
-rw-r--r--client/src/app/shared/video/video-actions-dropdown.component.ts5
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.ts38
3 files changed, 48 insertions, 21 deletions
diff --git a/client/src/app/shared/video-playlist/video-add-to-playlist.component.ts b/client/src/app/shared/video-playlist/video-add-to-playlist.component.ts
index 7dcdf7a9e..be15f2352 100644
--- a/client/src/app/shared/video-playlist/video-add-to-playlist.component.ts
+++ b/client/src/app/shared/video-playlist/video-add-to-playlist.component.ts
@@ -1,4 +1,4 @@
1import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core' 1import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'
2import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' 2import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service'
3import { AuthService, Notifier } from '@app/core' 3import { AuthService, Notifier } from '@app/core'
4import { forkJoin } from 'rxjs' 4import { forkJoin } from 'rxjs'
@@ -22,7 +22,7 @@ type PlaylistSummary = {
22 templateUrl: './video-add-to-playlist.component.html', 22 templateUrl: './video-add-to-playlist.component.html',
23 changeDetection: ChangeDetectionStrategy.OnPush 23 changeDetection: ChangeDetectionStrategy.OnPush
24}) 24})
25export class VideoAddToPlaylistComponent extends FormReactive implements OnInit { 25export class VideoAddToPlaylistComponent extends FormReactive implements OnInit, OnChanges {
26 @Input() video: Video 26 @Input() video: Video
27 @Input() currentVideoTimestamp: number 27 @Input() currentVideoTimestamp: number
28 @Input() lazyLoad = false 28 @Input() lazyLoad = false
@@ -54,15 +54,33 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit
54 } 54 }
55 55
56 ngOnInit () { 56 ngOnInit () {
57 this.resetOptions(true)
58
59 this.buildForm({ 57 this.buildForm({
60 displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME 58 displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME
61 }) 59 })
62 60
61 this.init()
62 }
63
64 ngOnChanges (simpleChanges: SimpleChanges) {
65 if (simpleChanges['video']) {
66 this.unload()
67 }
68 }
69
70 init () {
71 this.resetOptions(true)
72
63 if (this.lazyLoad !== true) this.load() 73 if (this.lazyLoad !== true) this.load()
64 } 74 }
65 75
76 unload () {
77 this.videoPlaylists = []
78
79 this.init()
80
81 this.cd.markForCheck()
82 }
83
66 load () { 84 load () {
67 forkJoin([ 85 forkJoin([
68 this.videoPlaylistService.listAccountPlaylists(this.user.account, '-updatedAt'), 86 this.videoPlaylistService.listAccountPlaylists(this.user.account, '-updatedAt'),
diff --git a/client/src/app/shared/video/video-actions-dropdown.component.ts b/client/src/app/shared/video/video-actions-dropdown.component.ts
index ee2f44f9e..df799499e 100644
--- a/client/src/app/shared/video/video-actions-dropdown.component.ts
+++ b/client/src/app/shared/video/video-actions-dropdown.component.ts
@@ -79,6 +79,11 @@ export class VideoActionsDropdownComponent implements OnChanges {
79 } 79 }
80 80
81 ngOnChanges () { 81 ngOnChanges () {
82 if (this.loaded) {
83 this.loaded = false
84 this.playlistAdd.unload()
85 }
86
82 this.buildActions() 87 this.buildActions()
83 } 88 }
84 89
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 b147b75b0..631504eab 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/videos/+video-watch/video-watch.component.ts
@@ -119,23 +119,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
119 if (videoId) this.loadVideo(videoId) 119 if (videoId) this.loadVideo(videoId)
120 }) 120 })
121 121
122 this.hotkeys = [ 122 this.initHotkeys()
123 new Hotkey('shift+l', (event: KeyboardEvent): boolean => {
124 this.setLike()
125 return false
126 }, undefined, this.i18n('Like the video')),
127 new Hotkey('shift+d', (event: KeyboardEvent): boolean => {
128 this.setDislike()
129 return false
130 }, undefined, this.i18n('Dislike the video')),
131 new Hotkey('shift+s', (event: KeyboardEvent): boolean => {
132 this.subscribeButton.subscribed ?
133 this.subscribeButton.unsubscribe() :
134 this.subscribeButton.subscribe()
135 return false
136 }, undefined, this.i18n('Subscribe to the account'))
137 ]
138 if (this.isUserLoggedIn()) this.hotkeysService.add(this.hotkeys)
139 } 123 }
140 124
141 ngOnDestroy () { 125 ngOnDestroy () {
@@ -565,4 +549,24 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
565 this.player = undefined 549 this.player = undefined
566 } 550 }
567 } 551 }
552
553 private initHotkeys () {
554 this.hotkeys = [
555 new Hotkey('shift+l', (event: KeyboardEvent): boolean => {
556 this.setLike()
557 return false
558 }, undefined, this.i18n('Like the video')),
559 new Hotkey('shift+d', (event: KeyboardEvent): boolean => {
560 this.setDislike()
561 return false
562 }, undefined, this.i18n('Dislike the video')),
563 new Hotkey('shift+s', (event: KeyboardEvent): boolean => {
564 this.subscribeButton.subscribed ?
565 this.subscribeButton.unsubscribe() :
566 this.subscribeButton.subscribe()
567 return false
568 }, undefined, this.i18n('Subscribe to the account'))
569 ]
570 if (this.isUserLoggedIn()) this.hotkeysService.add(this.hotkeys)
571 }
568} 572}