-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core'
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'
import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service'
import { AuthService, Notifier } from '@app/core'
import { forkJoin } from 'rxjs'
templateUrl: './video-add-to-playlist.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class VideoAddToPlaylistComponent extends FormReactive implements OnInit {
+export class VideoAddToPlaylistComponent extends FormReactive implements OnInit, OnChanges {
@Input() video: Video
@Input() currentVideoTimestamp: number
@Input() lazyLoad = false
}
ngOnInit () {
- this.resetOptions(true)
-
this.buildForm({
displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME
})
+ }
+
+ ngOnChanges (simpleChanges: SimpleChanges) {
+ if (simpleChanges['video']) {
+ this.reload()
+ }
+ }
+
+ init () {
+ this.resetOptions(true)
if (this.lazyLoad !== true) this.load()
}
+ reload () {
+ this.videoPlaylists = []
+
+ this.init()
+
+ this.cd.markForCheck()
+ }
+
load () {
forkJoin([
this.videoPlaylistService.listAccountPlaylists(this.user.account, '-updatedAt'),