fix(VideoAttributeView): Fix image and overflow_menu_on_tap props

This commit is contained in:
LuanRT
2023-11-30 23:34:31 -03:00
parent a32aa8c633
commit 5ae15be63d

View File

@@ -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;
@@ -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;
@@ -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;
}
}