chore(ytmusic): simplify home feed

This commit is contained in:
LuanRT
2022-06-17 16:32:13 -03:00
parent 4e1f6af736
commit 1efbef6f49
2 changed files with 8 additions and 8 deletions

View File

@@ -8,8 +8,12 @@ class MusicCarouselShelf {
constructor(data) {
this.header = Parser.parse(data.header);
this.contents = Parser.parse(data.contents);
this.item_size = data.itemSize || null;
this.num_items_per_column = data.numItemsPerColumn || null;
data.itemSize &&
(this.item_size = data.itemSize);
data.numItemsPerColumn &&
(this.num_items_per_column = data.numItemsPerColumn);
}
}

View File

@@ -18,15 +18,11 @@ class HomeFeed {
this.#page = Parser.parseResponse(response.data);
const tab = this.#page.contents.tabs.get({ title: 'Home' });
const section_list = tab.content?.contents || this.#page.continuation_contents.contents;
this.#continuation = tab.content?.continuation || this.#page.continuation_contents.continuation;
/** @type {{ sections: { header: import('../contents/classes/MusicCarouselShelfBasicHeader'), items: object[] }[] }} */
this.sections = observe(section_list.map((shelf) => ({
header: shelf.header,
items: shelf.contents
})));
/** @type {import('../contents/classes/MusicCarouselShelf')[]} */
this.sections = tab.content?.contents || this.#page.continuation_contents.contents;
}
/**