From 0f8f92a28a5b6143e890626b22ce570730a0cf09 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 11 Jul 2024 13:31:27 -0400 Subject: [PATCH] fix(parser): ThumbnailView background color (#686) --- src/parser/classes/CollectionThumbnailView.ts | 12 +++++++----- src/parser/classes/ThumbnailBadgeView.ts | 12 +++++++----- src/parser/classes/ThumbnailView.ts | 12 +++++++----- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/parser/classes/CollectionThumbnailView.ts b/src/parser/classes/CollectionThumbnailView.ts index 41783701..571da853 100644 --- a/src/parser/classes/CollectionThumbnailView.ts +++ b/src/parser/classes/CollectionThumbnailView.ts @@ -6,7 +6,7 @@ export default class CollectionThumbnailView extends YTNode { static type = 'CollectionThumbnailView'; primary_thumbnail: ThumbnailView | null; - stack_color: { + stack_color?: { light_theme: number; dark_theme: number; }; @@ -15,9 +15,11 @@ export default class CollectionThumbnailView extends YTNode { super(); this.primary_thumbnail = Parser.parseItem(data.primaryThumbnail, ThumbnailView); - this.stack_color = { - light_theme: data.stackColor.lightTheme, - dark_theme: data.stackColor.darkTheme - }; + if (data.stackColor) { + this.stack_color = { + light_theme: data.stackColor.lightTheme, + dark_theme: data.stackColor.darkTheme + }; + } } } \ No newline at end of file diff --git a/src/parser/classes/ThumbnailBadgeView.ts b/src/parser/classes/ThumbnailBadgeView.ts index 2a5fb9c3..249feb49 100644 --- a/src/parser/classes/ThumbnailBadgeView.ts +++ b/src/parser/classes/ThumbnailBadgeView.ts @@ -7,7 +7,7 @@ export default class ThumbnailBadgeView extends YTNode { icon_name: string; text: string; badge_style: string; - background_color: { + background_color?: { light_theme: number; dark_theme: number; }; @@ -18,9 +18,11 @@ export default class ThumbnailBadgeView extends YTNode { this.icon_name = data.icon.sources[0].clientResource.imageName; this.text = data.text; this.badge_style = data.badgeStyle; - this.background_color = { - light_theme: data.backgroundColor.lightTheme, - dark_theme: data.backgroundColor.darkTheme - }; + if (data.backgroundColor) { + this.background_color = { + light_theme: data.backgroundColor.lightTheme, + dark_theme: data.backgroundColor.darkTheme + }; + } } } \ No newline at end of file diff --git a/src/parser/classes/ThumbnailView.ts b/src/parser/classes/ThumbnailView.ts index b768f499..bb389e3b 100644 --- a/src/parser/classes/ThumbnailView.ts +++ b/src/parser/classes/ThumbnailView.ts @@ -9,7 +9,7 @@ export default class ThumbnailView extends YTNode { image: Thumbnail[]; overlays: (ThumbnailOverlayBadgeView | ThumbnailHoverOverlayView)[]; - background_color: { + background_color?: { light_theme: number; dark_theme: number; }; @@ -19,9 +19,11 @@ export default class ThumbnailView extends YTNode { this.image = Thumbnail.fromResponse(data.image); this.overlays = Parser.parseArray(data.overlays, [ ThumbnailOverlayBadgeView, ThumbnailHoverOverlayView ]); - this.background_color = { - light_theme: data.backgroundColor.lightTheme, - dark_theme: data.backgroundColor.darkTheme - }; + if (data.backgroundColor) { + this.background_color = { + light_theme: data.backgroundColor.lightTheme, + dark_theme: data.backgroundColor.darkTheme + }; + } } } \ No newline at end of file