mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-28 00:56:23 +00:00
fix: search continuations should return a Search class
Why? To keep things consistent.
This commit is contained in:
@@ -29,8 +29,8 @@ class History {
|
||||
this.feed_actions = secondary_contents?.contents || null;
|
||||
|
||||
this.sections = observe(contents.map((section) => ({
|
||||
title: section.header.title,
|
||||
items: section.contents
|
||||
header: section.header,
|
||||
contents: section.contents
|
||||
})));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ class Library {
|
||||
this.profile = { stats, user_info };
|
||||
|
||||
this.sections = observe(shelves.map((shelf) => ({
|
||||
title: shelf.title.toString(),
|
||||
items: shelf.content.items,
|
||||
type: shelf.icon_type,
|
||||
title: shelf.title.toString(),
|
||||
contents: shelf.content.items,
|
||||
getAll: () => this.#getAll(shelf)
|
||||
})));
|
||||
}
|
||||
|
||||
@@ -41,11 +41,11 @@ class Search extends Feed {
|
||||
header: card_list?.header || null,
|
||||
/** @type {import('../contents/classes/SearchRefinementCard')} */
|
||||
cards: card_list?.cards || []
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies given refinement card and returns a new {@link Feed} object.
|
||||
* Applies given refinement card and returns a new {@link Search} object.
|
||||
*
|
||||
* @param {import('../contents/classes/SearchRefinementCard') | string} card - refinement card object or query
|
||||
* @returns {Promise.<Feed>}
|
||||
@@ -66,13 +66,23 @@ class Search extends Feed {
|
||||
}
|
||||
|
||||
const page = await target_card.endpoint.call(this.actions);
|
||||
return new Feed(this.actions, page, true);
|
||||
return new Search(this.actions, page, true);
|
||||
}
|
||||
|
||||
/** @type {string[]} */
|
||||
get refinement_card_queries() {
|
||||
return this.refinement_cards.cards.map((card) => card.query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves next batch of results.
|
||||
*
|
||||
* @returns {Promise.<Search>}
|
||||
*/
|
||||
async getContinuation() {
|
||||
const continuation = await this.getContinuationData();
|
||||
return new Search(this.actions, continuation, true);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Search;
|
||||
Reference in New Issue
Block a user