Loading & error message services improvements
This commit is contained in:
parent
eb1204ad7e
commit
bc35a23bb2
@ -8,8 +8,13 @@ export class LoadingService {
|
||||
private readonly _loadingEvent$ = new BehaviorSubject(false);
|
||||
readonly isLoading$ = this._loadingEvent$.asObservable();
|
||||
private _loadingStarted = 0;
|
||||
private _timeout?: number;
|
||||
|
||||
start(): void {
|
||||
if (this._timeout) {
|
||||
clearTimeout(this._timeout);
|
||||
this._timeout = undefined;
|
||||
}
|
||||
setTimeout(() => {
|
||||
this._loadingEvent$.next(true);
|
||||
this._loadingStarted = new Date().getTime();
|
||||
@ -37,6 +42,6 @@ export class LoadingService {
|
||||
}
|
||||
|
||||
private _stopAfter(timeout: number): void {
|
||||
setTimeout(() => this._stop(), timeout);
|
||||
this._timeout = window.setTimeout(() => this._stop(), timeout);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,8 +8,10 @@ import { HttpErrorResponse } from '@angular/common/http';
|
||||
export class ErrorMessageService {
|
||||
constructor(private readonly _translateService: TranslateService) {}
|
||||
|
||||
getMessage(error: HttpErrorResponse, defaultMessage: string): string {
|
||||
return (this._translateService.instant(defaultMessage) as string) + this._parseErrorResponse(error);
|
||||
getMessage(error: HttpErrorResponse, defaultMessage?: string): string {
|
||||
return defaultMessage
|
||||
? (this._translateService.instant(defaultMessage) as string) + this._parseErrorResponse(error)
|
||||
: this._parseErrorResponse(error);
|
||||
}
|
||||
|
||||
private _parseErrorResponse(err: HttpErrorResponse): string {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user