From 52e3307d99b6f809c6a7a281b2a33bbc67c0e006 Mon Sep 17 00:00:00 2001 From: James Woglom Date: Tue, 30 Aug 2022 00:58:19 -0400 Subject: switch between audio and default custom directories on change --- ui/src/app/app.component.ts | 10 +++++++--- ui/src/app/downloads.service.ts | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'ui') diff --git a/ui/src/app/app.component.ts b/ui/src/app/app.component.ts index e716395..cdcd8f6 100644 --- a/ui/src/app/app.component.ts +++ b/ui/src/app/app.component.ts @@ -77,6 +77,8 @@ export class AppComponent implements AfterViewInit { qualityChanged() { this.cookieService.set('metube_quality', this.quality, { expires: 3650 }); + // Re-trigger custom directory change + this.downloads.customDirsChanged.next(this.downloads.customDirs); } showAdvanced() { @@ -88,13 +90,13 @@ export class AppComponent implements AfterViewInit { } getMatchingCustomDir() : Observable { - return this.downloads.customDirs.asObservable().pipe(map((output) => { + return this.downloads.customDirsChanged.asObservable().pipe(map((output) => { // Keep logic consistent with app/ytdl.py if (this.quality != 'audio' && this.format != 'mp3') { - console.debug("download_dir", output["download_dir"]) + console.debug("Showing default download directories"); return output["download_dir"]; } else { - console.debug("audio_download_dir", output["audio_download_dir"]) + console.debug("Showing audio-specific download directories"); return output["audio_download_dir"]; } })); @@ -125,6 +127,8 @@ export class AppComponent implements AfterViewInit { this.cookieService.set('metube_format', this.format, { expires: 3650 }); // Updates to use qualities available this.setQualities() + // Re-trigger custom directory change + this.downloads.customDirsChanged.next(this.downloads.customDirs); } queueSelectionChanged(checked: number) { diff --git a/ui/src/app/downloads.service.ts b/ui/src/app/downloads.service.ts index 1fd75e3..a2ea912 100644 --- a/ui/src/app/downloads.service.ts +++ b/ui/src/app/downloads.service.ts @@ -33,8 +33,10 @@ export class DownloadsService { done = new Map(); queueChanged = new Subject(); doneChanged = new Subject(); - customDirs = new Subject>(); + customDirsChanged = new Subject(); + configuration = {}; + customDirs = {}; constructor(private http: HttpClient, private socket: MeTubeSocket) { socket.fromEvent('all').subscribe((strdata: string) => { @@ -84,7 +86,8 @@ export class DownloadsService { socket.fromEvent('custom_dirs').subscribe((strdata: string) => { let data = JSON.parse(strdata); console.debug("got custom_dirs:", data); - this.customDirs.next(data); + this.customDirs = data; + this.customDirsChanged.next(data); }); } -- cgit