[auth] small refactor

This commit is contained in:
nymkappa 2024-02-10 10:31:56 +01:00
parent bb43599493
commit a2b01587b1
No known key found for this signature in database
GPG key ID: E155910B16E8BD04

View file

@ -4,7 +4,7 @@ import { HttpClient, HttpParams } from '@angular/common/http';
import { StateService } from './state.service';
import { StorageService } from './storage.service';
import { MenuGroup } from '../interfaces/services.interface';
import { Observable, of, ReplaySubject, tap, catchError, share } from 'rxjs';
import { Observable, of, ReplaySubject, tap, catchError, share, filter, switchMap } from 'rxjs';
import { IBackendInfo } from '../interfaces/websocket.interface';
import { Acceleration, AccelerationHistoryParams } from '../interfaces/node-api.interface';
@ -64,13 +64,10 @@ export class ServicesApiServices {
}
this.getUserInfo$().subscribe();
this.router.events.subscribe((event) => {
if (event instanceof NavigationStart) {
if (this.currentAuth !== localStorage.getItem('auth')) {
this.getUserInfo$().subscribe();
}
}
});
this.router.events.pipe(
filter((event) => event instanceof NavigationStart && this.currentAuth !== localStorage.getItem('auth')),
switchMap(() => this.getUserInfo$()),
).subscribe();
}
/**