From 4cbaa7983f35a82b9907197769672ac3b300bfbe Mon Sep 17 00:00:00 2001 From: Luan Date: Sun, 16 Jun 2024 15:39:47 -0300 Subject: [PATCH] fix(InfoPanelContent): Update InfoPanelContent node to also support `paragraphs` This would fail when `attributedParagraphs` was missing, so we still need `paragraphs` there. --- src/parser/classes/InfoPanelContent.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/parser/classes/InfoPanelContent.ts b/src/parser/classes/InfoPanelContent.ts index b25d9656..4fd82bca 100644 --- a/src/parser/classes/InfoPanelContent.ts +++ b/src/parser/classes/InfoPanelContent.ts @@ -10,7 +10,8 @@ export default class InfoPanelContent extends YTNode { title: Text; source: Text; - attributed_paragraphs: Text[]; + paragraphs?: Text[]; + attributed_paragraphs?: Text[]; thumbnail: Thumbnail[]; source_endpoint: NavigationEndpoint; truncate_paragraphs: boolean; @@ -21,7 +22,13 @@ export default class InfoPanelContent extends YTNode { super(); this.title = new Text(data.title); this.source = new Text(data.source); - this.attributed_paragraphs = data.attributedParagraphs.map((p: AttributedText) => Text.fromAttributed(p)); + + if (Reflect.has(data, 'paragraphs')) + this.paragraphs = data.paragraphs.map((p: RawNode) => new Text(p)); + + if (Reflect.has(data, 'attributedParagraphs')) + this.attributed_paragraphs = data.attributedParagraphs.map((p: AttributedText) => Text.fromAttributed(p)); + this.thumbnail = Thumbnail.fromResponse(data.thumbnail); this.source_endpoint = new NavigationEndpoint(data.sourceEndpoint); this.truncate_paragraphs = !!data.truncateParagraphs;