From 36b83673d81bebca4f4a967e727bf9310eaeec32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 20 Sep 2021 10:22:28 +0200 Subject: [PATCH] Accept that capabilities API may return an elements: undefined result --- frontend/src/app/core/apiv3/cache/cachable-apiv3-collection.ts | 2 +- frontend/src/app/core/current-user/current-user.service.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/core/apiv3/cache/cachable-apiv3-collection.ts b/frontend/src/app/core/apiv3/cache/cachable-apiv3-collection.ts index 73857b758d..8fd6b207e6 100644 --- a/frontend/src/app/core/apiv3/cache/cachable-apiv3-collection.ts +++ b/frontend/src/app/core/apiv3/cache/cachable-apiv3-collection.ts @@ -60,7 +60,7 @@ export abstract class CachableAPIV3Collection< tap( (response:R) => { if (response instanceof CollectionResource) { - response.elements.forEach(this.touch.bind(this)); + response.elements?.forEach(this.touch.bind(this)); } else if (response instanceof HalResource) { this.touch(response as any); } diff --git a/frontend/src/app/core/current-user/current-user.service.ts b/frontend/src/app/core/current-user/current-user.service.ts index b6e52707af..b5c107b8c2 100644 --- a/frontend/src/app/core/current-user/current-user.service.ts +++ b/frontend/src/app/core/current-user/current-user.service.ts @@ -124,6 +124,8 @@ export class CurrentUserService { // The current page is the only page, return the results. return of(data.elements); }), + // Elements may incorrectly be undefined here due to the way the representer works + map((elements) => elements || []), ) .subscribe((capabilities) => { this.currentUserStore.update((state) => ({