From dae08723793053d283a0a3d127d5e903e4fcee1b Mon Sep 17 00:00:00 2001 From: Jesse Lucas Date: Wed, 18 Mar 2020 19:39:01 -0400 Subject: [PATCH] Remove Folder object from array in development only --- src/app/db-status.service.ts | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/app/db-status.service.ts b/src/app/db-status.service.ts index 4c9e99797..67481bfe5 100644 --- a/src/app/db-status.service.ts +++ b/src/app/db-status.service.ts @@ -14,27 +14,38 @@ import { FolderStatus, Folder } from './folder' }) export class DbStatusService { private folderStatus: Object = {}; - - // TODO why isn't this working? - private httpOptions: { headers: HttpHeaders } | { params: HttpParams }; + private headers: HttpHeaders; private dbStatusUrl = environment.production ? apiURL + 'rest/db/status' : 'api/dbStatus'; constructor(private http: HttpClient, private cookieService: CookieService) { - this.httpOptions = { headers: new HttpHeaders(this.cookieService.getCSRFHeader()) }; + this.headers = new HttpHeaders(this.cookieService.getCSRFHeader()) } getFolderStatus(id: string): Observable { - /* + let httpOptions: { headers: HttpHeaders } | + { headers: HttpHeaders, params: HttpParams }; if (id) { - this.httpOptions["params"] = new HttpParams().set('folder', id); + httpOptions = { + headers: this.headers, + params: new HttpParams().set('folder', id) + }; + } else { + httpOptions = { headers: this.headers }; } - */ return this.http - .get(this.dbStatusUrl, this.httpOptions) + .get(this.dbStatusUrl, httpOptions) .pipe( retry(apiRetry), map(res => { + // Remove from array in developement + // in-memory-web-api returns arrays + if (!environment.production) { + const a: any = res as any; + if (a.length > 0) { + return res[0]; + } + } return res; }) );