Skip to content

Commit

Permalink
User Button class
Browse files Browse the repository at this point in the history
  • Loading branch information
dnicolson committed Jul 27, 2024
1 parent 0f8f92a commit 051709c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/parser/classes/menus/Menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ import { Parser } from '../../index.js';
import type { ObservedArray } from '../../helpers.js';
import { YTNode } from '../../helpers.js';
import type { RawNode } from '../../index.js';
import Button from '../Button.js';

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

items: ObservedArray<YTNode>;
top_level_buttons: ObservedArray<YTNode>;
top_level_buttons: ObservedArray<Button>;
label?: string;

constructor(data: RawNode) {
super();
this.items = Parser.parseArray(data.items);
this.top_level_buttons = Parser.parseArray(data.topLevelButtons);
this.top_level_buttons = Parser.parseArray(data.topLevelButtons, Button);

if (Reflect.has(data, 'accessibility') && Reflect.has(data.accessibility, 'accessibilityData')) {
this.label = data.accessibility.accessibilityData.label;
Expand Down
2 changes: 1 addition & 1 deletion src/parser/youtube/Library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Library extends Feed<IBrowseResponse> {
}

async #getAll(shelf: Shelf): Promise<Playlist | History | Feed> {
if (!shelf.menu?.as(Menu).hasKey('top_level_buttons'))
if (!shelf.menu?.as(Menu).top_level_buttons)
throw new InnertubeError(`The ${shelf.title.text} shelf doesn't have more items`);

const button = shelf.menu.as(Menu).top_level_buttons.firstOfType(Button);
Expand Down

0 comments on commit 051709c

Please sign in to comment.