feat(parser): Add ListView, ListItemView and SubscribeButtonView (#1025)

This commit is contained in:
absidue
2025-09-11 20:51:57 +02:00
committed by GitHub
parent 46c2f6c6c1
commit 68a6af9b2c
5 changed files with 126 additions and 2 deletions

View File

@@ -0,0 +1,32 @@
import type { ObservedArray } from '../helpers.js';
import type { RawNode } from '../types/RawResponse.js';
import { YTNode } from '../helpers.js';
import { Parser } from '../index.js';
import AvatarView from './AvatarView.js';
import RendererContext from './misc/RendererContext.js';
import SubscribeButtonView from './SubscribeButtonView.js';
import Text from './misc/Text.js';
export default class ListItemView extends YTNode {
static type = 'ListItemView';
public title: Text;
public subtitle: Text;
public leading_accessory: AvatarView | null;
public renderer_context: RendererContext;
public trailing_buttons?: ObservedArray<SubscribeButtonView>;
constructor(data: RawNode) {
super();
this.title = Text.fromAttributed(data.title);
this.subtitle = Text.fromAttributed(data.subtitle);
this.leading_accessory = Parser.parseItem(data.leadingAccessory, AvatarView);
this.renderer_context = new RendererContext(data.rendererContext);
if ('trailingButtons' in data) {
this.trailing_buttons = Parser.parseArray(data.trailingButtons.buttons, SubscribeButtonView);
}
}
}