From 389c2b246a6eb61529cfff5ca5d54e34b145b0e5 Mon Sep 17 00:00:00 2001 From: Saman Hosseini Date: Sun, 25 Sep 2022 01:15:51 +0200 Subject: [PATCH] fix(npm): handle `nil` arrays --- packages/media-entity/src/entities/gallery.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/media-entity/src/entities/gallery.ts b/packages/media-entity/src/entities/gallery.ts index e8f0972..212a24f 100644 --- a/packages/media-entity/src/entities/gallery.ts +++ b/packages/media-entity/src/entities/gallery.ts @@ -41,7 +41,7 @@ export function hydrateGallery( ): Gallery { return { ...data, - stacks: data.stacks.map((data) => hydrateStack(data)), + stacks: (data.stacks || []).map((data) => hydrateStack(data)), } } @@ -53,7 +53,8 @@ export function hydrateStack( ): Stack { return { ...data, - variants: data.variants.map(hydrateStackImage), + variants: (data.variants || []).map(hydrateStackImage), + tags: data.tags || [], } }