potentially made it so saved settings get applied with no reload in most situations

pull/29/head
Isaac Grynsztein 6 years ago
parent 4f4a82c3c4
commit bad4b8630b

@ -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 // loading config
this.postsService.loadNavItems().subscribe(res => { // loads settings this.postsService.loadNavItems().subscribe(res => { // loads settings
const result = !this.postsService.debugMode ? res['config_file'] : res; const result = !this.postsService.debugMode ? res['config_file'] : res;
@ -71,11 +85,6 @@ export class AppComponent implements OnInit {
}, error => { }, error => {
console.log(error); console.log(error);
}); });
}
toggleSidenav() {
this.sidenav.toggle();
} }
// theme stuff // theme stuff

@ -213,6 +213,25 @@ export class MainComponent implements OnInit {
private router: Router, public dialog: MatDialog, private platform: Platform, private route: ActivatedRoute) { private router: Router, public dialog: MatDialog, private platform: Platform, private route: ActivatedRoute) {
this.audioOnly = false; 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 // loading config
this.postsService.loadNavItems().subscribe(res => { // loads settings this.postsService.loadNavItems().subscribe(res => { // loads settings
const result = !this.postsService.debugMode ? res['config_file'] : res; 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 (youtubeUsername && youtubeUsername !== 'null') { this.youtubeUsername = youtubeUsername };
} }
if (this.autoStartDownload) { return true;
this.downloadClicked();
}
setInterval(() => this.getSimulatedOutput(), 1000);
}, error => { }, error => {
console.log(error); console.log(error);
});
return false;
});
} }
// app initialization. // app initialization.

@ -9,6 +9,7 @@ import 'rxjs/add/observable/throw';
import { THEMES_CONFIG } from '../themes'; import { THEMES_CONFIG } from '../themes';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { DOCUMENT } from '@angular/common'; import { DOCUMENT } from '@angular/common';
import { BehaviorSubject } from 'rxjs';
@Injectable() @Injectable()
export class PostsService { export class PostsService {
@ -20,6 +21,7 @@ export class PostsService {
handShakeComplete = false; handShakeComplete = false;
THEMES_CONFIG = THEMES_CONFIG; THEMES_CONFIG = THEMES_CONFIG;
theme; theme;
settings_changed = new BehaviorSubject<boolean>(false);
debugMode = false; debugMode = false;
constructor(private http: HttpClient, private router: Router, @Inject(DOCUMENT) private document: Document) { 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 => { this.postsService.setConfig(settingsToSave).subscribe(res => {
if (res['success']) { if (res['success']) {
// sets new config as old config // sets new config as old config
this.postsService.settings_changed.next(true);
this.initial_config = JSON.parse(JSON.stringify(this.new_config)); this.initial_config = JSON.parse(JSON.stringify(this.new_config));
} }
}, err => { }, err => {

Loading…
Cancel
Save