Skip to content

Commit

Permalink
fix(VideoAttributeView): Fix image and overflow_menu_on_tap props
Browse files Browse the repository at this point in the history
  • Loading branch information
LuanRT committed Dec 1, 2023
1 parent a32aa8c commit 5ae15be
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/parser/classes/VideoAttributeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import ContentPreviewImageView from './ContentPreviewImageView.js';
import { Parser } from '../index.js';

import type { RawNode } from '../types/index.js';
import Thumbnail from './misc/Thumbnail.js';

export default class VideoAttributeView extends YTNode {
static type = 'VideoAttributeView';

image: ContentPreviewImageView | null;
image: ContentPreviewImageView | {
sources: Thumbnail[];
} | null;
image_style: string;
title: string;
subtitle: string;
Expand All @@ -18,14 +21,20 @@ export default class VideoAttributeView extends YTNode {
};
orientation: string;
sizing_rule: string;
overflow_menu_on_tap: {
innertube_command: NavigationEndpoint
};
overflow_menu_on_tap: NavigationEndpoint;
overflow_menu_a11y_label: string;

constructor(data: RawNode) {
super();
this.image = Parser.parseItem(data.image, ContentPreviewImageView);
// @NOTE: "image" is not a renderer so not sure why we're parsing it as one. Leaving this hack here for now to avoid breaking things.
if (data.image?.sources) {
this.image = {
sources: data.image.sources.map((x: any) => new Thumbnail(x)).sort((a: Thumbnail, b: Thumbnail) => b.width - a.width)
};
} else {
this.image = Parser.parseItem(data.image, ContentPreviewImageView);
}

this.image_style = data.imageStyle;
this.title = data.title;
this.subtitle = data.subtitle;
Expand All @@ -34,9 +43,7 @@ export default class VideoAttributeView extends YTNode {
};
this.orientation = data.orientation;
this.sizing_rule = data.sizingRule;
this.overflow_menu_on_tap = {
innertube_command: new NavigationEndpoint(data.overflowMenuOnTap.innertubeCommand)
};
this.overflow_menu_on_tap = new NavigationEndpoint(data.overflowMenuOnTap);
this.overflow_menu_a11y_label = data.overflowMenuA11yLabel;
}
}

0 comments on commit 5ae15be

Please sign in to comment.