Skip to content

Commit

Permalink
fix(DescriptionPreviewView): Parsing errors when certain fields are m…
Browse files Browse the repository at this point in the history
…issing
  • Loading branch information
LuanRT committed Dec 31, 2024
1 parent 88af6d8 commit c2dd803
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/parser/classes/DescriptionPreviewView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import Text from './misc/Text.js';
export default class DescriptionPreviewView extends YTNode {
static type = 'DescriptionPreviewView';

description: Text;
max_lines: number;
truncation_text: Text;
description?: Text;
max_lines?: number;
truncation_text?: Text;
always_show_truncation_text: boolean;
more_endpoint?: {
show_engagement_panel_endpoint: {
Expand All @@ -24,9 +24,15 @@ export default class DescriptionPreviewView extends YTNode {
constructor(data: RawNode) {
super();

this.description = Text.fromAttributed(data.description);
this.max_lines = parseInt(data.maxLines);
this.truncation_text = Text.fromAttributed(data.truncationText);
if (Reflect.has(data, 'description'))
this.description = Text.fromAttributed(data.description);

if (Reflect.has(data, 'maxLines'))
this.max_lines = parseInt(data.maxLines);

if (Reflect.has(data, 'truncationText'))
this.truncation_text = Text.fromAttributed(data.truncationText);

this.always_show_truncation_text = !!data.alwaysShowTruncationText;

if (data.rendererContext.commandContext?.onTap?.innertubeCommand?.showEngagementPanelEndpoint) {
Expand Down

0 comments on commit c2dd803

Please sign in to comment.