Skip to content

Commit

Permalink
fix(InfoPanelContent): Update InfoPanelContent node to also support `…
Browse files Browse the repository at this point in the history
…paragraphs`

This would fail when `attributedParagraphs` was missing, so we still need `paragraphs` there.
  • Loading branch information
LuanRT committed Jun 16, 2024
1 parent 9802483 commit 4cbaa79
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/parser/classes/InfoPanelContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 4cbaa79

Please sign in to comment.