From a68ecfa7306c466a4f866ab77b4db966d1789adc Mon Sep 17 00:00:00 2001 From: Isaac Grynsztein Date: Mon, 29 Jun 2020 20:06:37 -0400 Subject: [PATCH] Modifying playlist in dialog will now update the file manager automatically --- .../dialogs/modify-playlist/modify-playlist.component.ts | 2 ++ src/app/file-card/file-card.component.ts | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/app/dialogs/modify-playlist/modify-playlist.component.ts b/src/app/dialogs/modify-playlist/modify-playlist.component.ts index c6a33b4..18db662 100644 --- a/src/app/dialogs/modify-playlist/modify-playlist.component.ts +++ b/src/app/dialogs/modify-playlist/modify-playlist.component.ts @@ -14,6 +14,7 @@ export class ModifyPlaylistComponent implements OnInit { playlist = null; available_files = []; all_files = []; + playlist_updated = false; constructor(@Inject(MAT_DIALOG_DATA) public data: any, private postsService: PostsService, @@ -46,6 +47,7 @@ export class ModifyPlaylistComponent implements OnInit { updatePlaylist() { this.postsService.updatePlaylist(this.playlist).subscribe(res => { + this.playlist_updated = true; this.postsService.openSnackBar('Playlist updated successfully.'); this.getPlaylist(); }); diff --git a/src/app/file-card/file-card.component.ts b/src/app/file-card/file-card.component.ts index 9f76f2e..280d131 100644 --- a/src/app/file-card/file-card.component.ts +++ b/src/app/file-card/file-card.component.ts @@ -88,6 +88,15 @@ export class FileCardComponent implements OnInit { width: '65vw' } }); + + dialogRef.afterClosed().subscribe(res => { + // updates playlist in file manager if it changed + if (dialogRef.componentInstance.playlist_updated) { + this.playlist = dialogRef.componentInstance.original_playlist; + this.title = this.playlist.name; + this.count = this.playlist.fileNames.length; + } + }); } onImgError(event) {