diff --git a/src/app/dialogs/user-profile-dialog/user-profile-dialog.component.html b/src/app/dialogs/user-profile-dialog/user-profile-dialog.component.html
index fd9be71..c3bb84f 100644
--- a/src/app/dialogs/user-profile-dialog/user-profile-dialog.component.html
+++ b/src/app/dialogs/user-profile-dialog/user-profile-dialog.component.html
@@ -9,7 +9,7 @@
UID: {{postsService.user.uid}}
- Created: {{postsService.user.created ? postsService.user.created : 'N/A'}}
+ Created: {{postsService.user.created ? (postsService.user.created | date) : 'N/A'}}
diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts
index 0645c9b..36bd9f2 100644
--- a/src/app/main/main.component.ts
+++ b/src/app/main/main.component.ts
@@ -196,7 +196,6 @@ export class MainComponent implements OnInit {
selectedQuality = '';
formats_loading = false;
- config_loaded = false;
@ViewChild('urlinput', { read: ElementRef }) urlInput: ElementRef;
@ViewChildren('audiofilecard') audioFileCards: QueryList;
@@ -295,12 +294,11 @@ export class MainComponent implements OnInit {
// app initialization.
ngOnInit() {
- if (this.postsService.config) {
+ if (this.postsService.initialized) {
this.configLoad();
} else {
- this.postsService.config_reloaded.subscribe(changed => {
- if (changed && !this.config_loaded) {
- this.config_loaded = true;
+ this.postsService.service_initialized.subscribe(init => {
+ if (init) {
this.configLoad();
}
});
diff --git a/src/app/player/player.component.ts b/src/app/player/player.component.ts
index 0377063..84bba1c 100644
--- a/src/app/player/player.component.ts
+++ b/src/app/player/player.component.ts
@@ -79,11 +79,11 @@ export class PlayerComponent implements OnInit {
this.uuid = this.route.snapshot.paramMap.get('uuid');
// loading config
- if (this.postsService.config) {
+ if (this.postsService.initialized) {
this.processConfig();
} else {
- this.postsService.config_reloaded.subscribe(changed => { // loads settings
- if (changed) {
+ this.postsService.service_initialized.subscribe(init => { // loads settings
+ if (init) {
this.processConfig();
}
});
diff --git a/src/app/posts.services.ts b/src/app/posts.services.ts
index 8fb2a2f..ea47db8 100644
--- a/src/app/posts.services.ts
+++ b/src/app/posts.services.ts
@@ -36,6 +36,8 @@ export class PostsService implements CanActivate {
reload_config = new BehaviorSubject(false);
config_reloaded = new BehaviorSubject(false);
+ service_initialized = new BehaviorSubject(false);
+ initialized = false;
config = null;
constructor(private http: HttpClient, private router: Router, @Inject(DOCUMENT) private document: Document,
@@ -75,7 +77,7 @@ export class PostsService implements CanActivate {
this.jwtAuth();
}
} else {
- this.config_reloaded.next(true);
+ this.setInitialized();
}
}
});
@@ -328,6 +330,9 @@ export class PostsService implements CanActivate {
}),
};
+ // needed to re-initialize parts of app after login
+ this.config_reloaded.next(true);
+
if (this.router.url === '/login') {
this.router.navigate(['/home']);
}
@@ -350,7 +355,7 @@ export class PostsService implements CanActivate {
call.subscribe(res => {
if (res['token']) {
this.afterLogin(res['user'], res['token']);
- this.config_reloaded.next(true);
+ this.setInitialized();
}
}, err => {
if (err.status === 401) {
@@ -403,6 +408,12 @@ export class PostsService implements CanActivate {
this.openSnackBar('You must log in to access this page!');
}
+ setInitialized() {
+ this.service_initialized.next(true);
+ this.initialized = true;
+ this.config_reloaded.next(true);
+ }
+
public openSnackBar(message: string, action: string = '') {
this.snackBar.open(message, action, {
duration: 2000,
diff --git a/src/app/subscription/subscription/subscription.component.ts b/src/app/subscription/subscription/subscription.component.ts
index cd7037c..2226ba6 100644
--- a/src/app/subscription/subscription/subscription.component.ts
+++ b/src/app/subscription/subscription/subscription.component.ts
@@ -49,8 +49,8 @@ export class SubscriptionComponent implements OnInit {
if (this.route.snapshot.paramMap.get('id')) {
this.id = this.route.snapshot.paramMap.get('id');
- this.postsService.config_reloaded.subscribe(changed => {
- if (changed) {
+ this.postsService.service_initialized.subscribe(init => {
+ if (init) {
this.getConfig();
this.getSubscription();
}
diff --git a/src/app/subscriptions/subscriptions.component.ts b/src/app/subscriptions/subscriptions.component.ts
index 01ab0ea..1723bfd 100644
--- a/src/app/subscriptions/subscriptions.component.ts
+++ b/src/app/subscriptions/subscriptions.component.ts
@@ -22,11 +22,11 @@ export class SubscriptionsComponent implements OnInit {
constructor(private dialog: MatDialog, public postsService: PostsService, private router: Router, private snackBar: MatSnackBar) { }
ngOnInit() {
- if (this.postsService.config) {
+ if (this.postsService.initialized) {
this.getSubscriptions();
}
- this.postsService.config_reloaded.subscribe(changed => {
- if (changed) {
+ this.postsService.service_initialized.subscribe(init => {
+ if (init) {
this.getSubscriptions();
}
});