aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-05-17 14:34:21 +0200
committerChocobozzz <me@florianbigard.com>2019-05-17 14:34:21 +0200
commit1c8ddbfaa03e241c782201343d424748efc191c1 (patch)
tree7e1f4b4108b3c500aa5e353e1f0ec903994d633c /client/src/app/shared
parent67c687236f84dd288f2df3201c8ab77b93682b67 (diff)
downloadPeerTube-1c8ddbfaa03e241c782201343d424748efc191c1.tar.gz
PeerTube-1c8ddbfaa03e241c782201343d424748efc191c1.tar.zst
PeerTube-1c8ddbfaa03e241c782201343d424748efc191c1.zip
Reset playlist add component when video changes
Diffstat (limited to 'client/src/app/shared')
-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
2 files changed, 27 insertions, 4 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