From b1e627eedc8410828ac9ec3ec85d5d01bf67a8b0 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Wed, 26 Jul 2017 10:39:14 +0100 Subject: [PATCH] fix the favorites api (#2129) - fix the crash related to remapping entities --- .../src/services/favorites-api.service.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ng2-components/ng2-alfresco-core/src/services/favorites-api.service.ts b/ng2-components/ng2-alfresco-core/src/services/favorites-api.service.ts index c36adb4bfd..1140bee229 100644 --- a/ng2-components/ng2-alfresco-core/src/services/favorites-api.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/favorites-api.service.ts @@ -23,17 +23,18 @@ import { UserPreferencesService } from './user-preferences.service'; @Injectable() export class FavoritesApiService { - private remapFavoritesData(data: any = {}): NodePaging { + static remapFavoritesData(data: any = {}): NodePaging { const list = (data.list || {}); const pagination = (list.pagination || {}); - const entries: any[] = this.remapFavoriteEntries(list.entries || []); + const entries: any[] = FavoritesApiService + .remapFavoriteEntries(list.entries || []); return { list: { entries, pagination } }; } - private remapEntry({ entry }: any): any { + static remapEntry({ entry }: any): any { entry.createdAt = new Date(entry.createdAt); entry.modifiedAt = new Date(entry.modifiedAt); @@ -45,13 +46,13 @@ export class FavoritesApiService { return { entry }; } - private remapFavoriteEntries(entries: any[]) { + static remapFavoriteEntries(entries: any[]) { return entries .map(({ entry: { target }}: any) => ({ entry: target.file || target.folder })) .filter(({ entry }) => (!!entry)) - .map(this.remapEntry); + .map(FavoritesApiService.remapEntry); } constructor( @@ -74,7 +75,7 @@ export class FavoritesApiService { const queryOptions = Object.assign(defaultOptions, options); const promise = favoritesApi .getFavorites(personId, queryOptions) - .then(this.remapFavoritesData); + .then(FavoritesApiService.remapFavoritesData); return Observable .fromPromise(promise)