feat(Parser): Add AvatarStackView

This commit is contained in:
Luan
2024-12-31 06:05:49 -03:00
parent 3a11b99429
commit c6310228fe
3 changed files with 34 additions and 3 deletions

View File

@@ -1,24 +1,28 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
import { Text } from '../misc.js';
import { Parser } from '../index.js';
import AvatarStackView from './AvatarStackView.js';
export type MetadataRow = {
metadata_parts?: {
text: Text;
avatar_stack: AvatarStackView | null;
}[];
};
export default class ContentMetadataView extends YTNode {
static type = 'ContentMetadataView';
metadata_rows: MetadataRow[];
delimiter: string;
public metadata_rows: MetadataRow[];
public delimiter: string;
constructor(data: RawNode) {
super();
this.metadata_rows = data.metadataRows.map((row: RawNode) => ({
metadata_parts: row.metadataParts?.map((part: RawNode) => ({
text: Text.fromAttributed(part.text || {})
text: Text.fromAttributed(part.text || {}),
avatar_stack: Parser.parseItem(part.avatarStack, AvatarStackView)
}))
}));
this.delimiter = data.delimiter;