mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-23 15:30:34 -04:00
Coding style
This commit is contained in:
parent
25acb3188d
commit
33d8759e0f
@ -1,9 +1,9 @@
|
|||||||
import {HttpClient, HttpErrorResponse} from '@angular/common/http';
|
import { HttpClient, HttpErrorResponse } from "@angular/common/http";
|
||||||
import {Injectable} from '@angular/core';
|
import { Injectable } from "@angular/core";
|
||||||
import {MatSnackBar} from '@angular/material/snack-bar';
|
import { MatSnackBar } from "@angular/material/snack-bar";
|
||||||
import {ActivatedRouteSnapshot, Resolve} from '@angular/router';
|
import { ActivatedRouteSnapshot, Resolve } from "@angular/router";
|
||||||
import {Observable, EMPTY} from 'rxjs';
|
import { Observable, EMPTY } from "rxjs";
|
||||||
import {catchError} from 'rxjs/operators';
|
import { catchError } from "rxjs/operators";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ItemResolver
|
export class ItemResolver
|
||||||
@ -21,17 +21,17 @@ export class ItemResolver
|
|||||||
|
|
||||||
resolve(route: ActivatedRouteSnapshot): T | Observable<T> | Promise<T>
|
resolve(route: ActivatedRouteSnapshot): T | Observable<T> | Promise<T>
|
||||||
{
|
{
|
||||||
let res: string = resource.replace(/:(.*?)(\/|$)/, (x, y) => `${route.paramMap.get(y)}/`);
|
const res: string = resource.replace(/:(.*?)(\/|$)/, (x, y) => `${route.paramMap.get(y)}/`);
|
||||||
|
|
||||||
return this.http.get<T>(`api/${res}`)
|
return this.http.get<T>(`api/${res}`)
|
||||||
.pipe(
|
.pipe(
|
||||||
catchError((error: HttpErrorResponse) =>
|
catchError((error: HttpErrorResponse) =>
|
||||||
{
|
{
|
||||||
if (error.status == 404)
|
if (error.status === 404)
|
||||||
{
|
{
|
||||||
this.snackBar.open(`Item not found.`, null, {
|
this.snackBar.open("Item not found.", null, {
|
||||||
horizontalPosition: "left",
|
horizontalPosition: "left",
|
||||||
panelClass: ['snackError'],
|
panelClass: ["snackError"],
|
||||||
duration: 2500
|
duration: 2500
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ export class ItemResolver
|
|||||||
console.log(error.status + " - " + error.message);
|
console.log(error.status + " - " + error.message);
|
||||||
this.snackBar.open(`An unknown error occurred: ${error.message}.`, null, {
|
this.snackBar.open(`An unknown error occurred: ${error.message}.`, null, {
|
||||||
horizontalPosition: "left",
|
horizontalPosition: "left",
|
||||||
panelClass: ['snackError'],
|
panelClass: ["snackError"],
|
||||||
duration: 2500
|
duration: 2500
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user