mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-27 07:00:55 +03:00
potentially made it so saved settings get applied with no reload in most situations
This commit is contained in:
@@ -55,6 +55,20 @@ export class AppComponent implements OnInit {
|
||||
}
|
||||
});
|
||||
|
||||
this.loadConfig();
|
||||
this.postsService.settings_changed.subscribe(changed => {
|
||||
if (changed) {
|
||||
this.loadConfig();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
toggleSidenav() {
|
||||
this.sidenav.toggle();
|
||||
}
|
||||
|
||||
loadConfig() {
|
||||
// loading config
|
||||
this.postsService.loadNavItems().subscribe(res => { // loads settings
|
||||
const result = !this.postsService.debugMode ? res['config_file'] : res;
|
||||
@@ -71,11 +85,6 @@ export class AppComponent implements OnInit {
|
||||
}, error => {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
toggleSidenav() {
|
||||
this.sidenav.toggle();
|
||||
}
|
||||
|
||||
// theme stuff
|
||||
|
||||
@@ -213,6 +213,25 @@ export class MainComponent implements OnInit {
|
||||
private router: Router, public dialog: MatDialog, private platform: Platform, private route: ActivatedRoute) {
|
||||
this.audioOnly = false;
|
||||
|
||||
this.configLoad();
|
||||
|
||||
this.postsService.settings_changed.subscribe(changed => {
|
||||
if (changed) {
|
||||
this.loadConfig();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async configLoad() {
|
||||
await this.loadConfig();
|
||||
if (this.autoStartDownload) {
|
||||
this.downloadClicked();
|
||||
}
|
||||
|
||||
setInterval(() => this.getSimulatedOutput(), 1000);
|
||||
}
|
||||
|
||||
async loadConfig() {
|
||||
// loading config
|
||||
this.postsService.loadNavItems().subscribe(res => { // loads settings
|
||||
const result = !this.postsService.debugMode ? res['config_file'] : res;
|
||||
@@ -266,16 +285,13 @@ export class MainComponent implements OnInit {
|
||||
if (youtubeUsername && youtubeUsername !== 'null') { this.youtubeUsername = youtubeUsername };
|
||||
}
|
||||
|
||||
if (this.autoStartDownload) {
|
||||
this.downloadClicked();
|
||||
}
|
||||
|
||||
setInterval(() => this.getSimulatedOutput(), 1000);
|
||||
return true;
|
||||
|
||||
}, error => {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// app initialization.
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'rxjs/add/observable/throw';
|
||||
import { THEMES_CONFIG } from '../themes';
|
||||
import { Router } from '@angular/router';
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class PostsService {
|
||||
@@ -20,6 +21,7 @@ export class PostsService {
|
||||
handShakeComplete = false;
|
||||
THEMES_CONFIG = THEMES_CONFIG;
|
||||
theme;
|
||||
settings_changed = new BehaviorSubject<boolean>(false);
|
||||
|
||||
debugMode = false;
|
||||
constructor(private http: HttpClient, private router: Router, @Inject(DOCUMENT) private document: Document) {
|
||||
|
||||
@@ -38,6 +38,7 @@ export class SettingsComponent implements OnInit {
|
||||
this.postsService.setConfig(settingsToSave).subscribe(res => {
|
||||
if (res['success']) {
|
||||
// sets new config as old config
|
||||
this.postsService.settings_changed.next(true);
|
||||
this.initial_config = JSON.parse(JSON.stringify(this.new_config));
|
||||
}
|
||||
}, err => {
|
||||
|
||||
Reference in New Issue
Block a user