mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-21 05:13:19 +03:00
Refactored initialization process to better facilitate auth if necessary
Date in user profile dialog now shows date
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
<strong><ng-container i18n="UID">UID:</ng-container></strong> {{postsService.user.uid}}
|
<strong><ng-container i18n="UID">UID:</ng-container></strong> {{postsService.user.uid}}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<strong><ng-container i18n="Created">Created:</ng-container></strong> {{postsService.user.created ? postsService.user.created : 'N/A'}}
|
<strong><ng-container i18n="Created">Created:</ng-container></strong> {{postsService.user.created ? (postsService.user.created | date) : 'N/A'}}
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top: 20px;">
|
<div style="margin-top: 20px;">
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -196,7 +196,6 @@ export class MainComponent implements OnInit {
|
|||||||
|
|
||||||
selectedQuality = '';
|
selectedQuality = '';
|
||||||
formats_loading = false;
|
formats_loading = false;
|
||||||
config_loaded = false;
|
|
||||||
|
|
||||||
@ViewChild('urlinput', { read: ElementRef }) urlInput: ElementRef;
|
@ViewChild('urlinput', { read: ElementRef }) urlInput: ElementRef;
|
||||||
@ViewChildren('audiofilecard') audioFileCards: QueryList<FileCardComponent>;
|
@ViewChildren('audiofilecard') audioFileCards: QueryList<FileCardComponent>;
|
||||||
@@ -295,12 +294,11 @@ export class MainComponent implements OnInit {
|
|||||||
|
|
||||||
// app initialization.
|
// app initialization.
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.postsService.config) {
|
if (this.postsService.initialized) {
|
||||||
this.configLoad();
|
this.configLoad();
|
||||||
} else {
|
} else {
|
||||||
this.postsService.config_reloaded.subscribe(changed => {
|
this.postsService.service_initialized.subscribe(init => {
|
||||||
if (changed && !this.config_loaded) {
|
if (init) {
|
||||||
this.config_loaded = true;
|
|
||||||
this.configLoad();
|
this.configLoad();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -79,11 +79,11 @@ export class PlayerComponent implements OnInit {
|
|||||||
this.uuid = this.route.snapshot.paramMap.get('uuid');
|
this.uuid = this.route.snapshot.paramMap.get('uuid');
|
||||||
|
|
||||||
// loading config
|
// loading config
|
||||||
if (this.postsService.config) {
|
if (this.postsService.initialized) {
|
||||||
this.processConfig();
|
this.processConfig();
|
||||||
} else {
|
} else {
|
||||||
this.postsService.config_reloaded.subscribe(changed => { // loads settings
|
this.postsService.service_initialized.subscribe(init => { // loads settings
|
||||||
if (changed) {
|
if (init) {
|
||||||
this.processConfig();
|
this.processConfig();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ export class PostsService implements CanActivate {
|
|||||||
|
|
||||||
reload_config = new BehaviorSubject<boolean>(false);
|
reload_config = new BehaviorSubject<boolean>(false);
|
||||||
config_reloaded = new BehaviorSubject<boolean>(false);
|
config_reloaded = new BehaviorSubject<boolean>(false);
|
||||||
|
service_initialized = new BehaviorSubject<boolean>(false);
|
||||||
|
initialized = false;
|
||||||
|
|
||||||
config = null;
|
config = null;
|
||||||
constructor(private http: HttpClient, private router: Router, @Inject(DOCUMENT) private document: Document,
|
constructor(private http: HttpClient, private router: Router, @Inject(DOCUMENT) private document: Document,
|
||||||
@@ -75,7 +77,7 @@ export class PostsService implements CanActivate {
|
|||||||
this.jwtAuth();
|
this.jwtAuth();
|
||||||
}
|
}
|
||||||
} else {
|
} 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') {
|
if (this.router.url === '/login') {
|
||||||
this.router.navigate(['/home']);
|
this.router.navigate(['/home']);
|
||||||
}
|
}
|
||||||
@@ -350,7 +355,7 @@ export class PostsService implements CanActivate {
|
|||||||
call.subscribe(res => {
|
call.subscribe(res => {
|
||||||
if (res['token']) {
|
if (res['token']) {
|
||||||
this.afterLogin(res['user'], res['token']);
|
this.afterLogin(res['user'], res['token']);
|
||||||
this.config_reloaded.next(true);
|
this.setInitialized();
|
||||||
}
|
}
|
||||||
}, err => {
|
}, err => {
|
||||||
if (err.status === 401) {
|
if (err.status === 401) {
|
||||||
@@ -403,6 +408,12 @@ export class PostsService implements CanActivate {
|
|||||||
this.openSnackBar('You must log in to access this page!');
|
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 = '') {
|
public openSnackBar(message: string, action: string = '') {
|
||||||
this.snackBar.open(message, action, {
|
this.snackBar.open(message, action, {
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ export class SubscriptionComponent implements OnInit {
|
|||||||
if (this.route.snapshot.paramMap.get('id')) {
|
if (this.route.snapshot.paramMap.get('id')) {
|
||||||
this.id = this.route.snapshot.paramMap.get('id');
|
this.id = this.route.snapshot.paramMap.get('id');
|
||||||
|
|
||||||
this.postsService.config_reloaded.subscribe(changed => {
|
this.postsService.service_initialized.subscribe(init => {
|
||||||
if (changed) {
|
if (init) {
|
||||||
this.getConfig();
|
this.getConfig();
|
||||||
this.getSubscription();
|
this.getSubscription();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ export class SubscriptionsComponent implements OnInit {
|
|||||||
constructor(private dialog: MatDialog, public postsService: PostsService, private router: Router, private snackBar: MatSnackBar) { }
|
constructor(private dialog: MatDialog, public postsService: PostsService, private router: Router, private snackBar: MatSnackBar) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.postsService.config) {
|
if (this.postsService.initialized) {
|
||||||
this.getSubscriptions();
|
this.getSubscriptions();
|
||||||
}
|
}
|
||||||
this.postsService.config_reloaded.subscribe(changed => {
|
this.postsService.service_initialized.subscribe(init => {
|
||||||
if (changed) {
|
if (init) {
|
||||||
this.getSubscriptions();
|
this.getSubscriptions();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user