aboutsummaryrefslogtreecommitdiff
path: root/ui/src/app
diff options
context:
space:
mode:
authorJames Woglom <j@wogloms.net>2022-08-30 00:58:19 -0400
committerJames Woglom <j@wogloms.net>2022-08-30 00:58:19 -0400
commit52e3307d99b6f809c6a7a281b2a33bbc67c0e006 (patch)
treed44c7758ed9422bc4cdea97783e2fa12fca563e7 /ui/src/app
parentFill in download_dir or audio_download_dir on launch (diff)
downloadmetube-52e3307d99b6f809c6a7a281b2a33bbc67c0e006.tar.gz
metube-52e3307d99b6f809c6a7a281b2a33bbc67c0e006.tar.bz2
metube-52e3307d99b6f809c6a7a281b2a33bbc67c0e006.zip
switch between audio and default custom directories on change
Diffstat (limited to 'ui/src/app')
-rw-r--r--ui/src/app/app.component.ts10
-rw-r--r--ui/src/app/downloads.service.ts7
2 files changed, 12 insertions, 5 deletions
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<string[]> {
- 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<string, Download>();
queueChanged = new Subject();
doneChanged = new Subject();
- customDirs = new Subject<Map<string, string[]>>();
+ 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);
});
}
bgstack15