mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 20:41:17 +00:00
fix: search continuations should return a Search class
Why? To keep things consistent.
This commit is contained in:
@@ -8,9 +8,16 @@ class Button {
|
||||
|
||||
constructor(data) {
|
||||
this.text = new Text(data.text).toString();
|
||||
this.label = data.accessibility?.label || null;
|
||||
this.tooltip = data.tooltip || null;
|
||||
this.icon_type = data.icon?.iconType || null;
|
||||
|
||||
data.accessibility?.label &&
|
||||
(this.label = data.accessibility?.label);
|
||||
|
||||
data.tooltip &&
|
||||
(this.tooltip = data.tooltip);
|
||||
|
||||
data.icon?.iconType &&
|
||||
(this.icon_type = data.icon?.iconType);
|
||||
|
||||
this.endpoint = new NavigationEndpoint(data.navigationEndpoint || data.serviceEndpoint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,12 @@ class Parser {
|
||||
const on_response_received_endpoints = data.onResponseReceivedEndpoints && Parser.parseRR(data.onResponseReceivedEndpoints) || null;
|
||||
const on_response_received_endpoints_memo = Parser.#memo;
|
||||
this.#clearMemo();
|
||||
|
||||
|
||||
this.#createMemo();
|
||||
const on_response_received_commands = data.onResponseReceivedCommands && Parser.parseRR(data.onResponseReceivedCommands) || null;
|
||||
const on_response_received_commands_memo = Parser.#memo;
|
||||
this.#clearMemo();
|
||||
|
||||
return {
|
||||
contents,
|
||||
contents_memo,
|
||||
@@ -69,7 +74,8 @@ class Parser {
|
||||
on_response_received_actions_memo,
|
||||
on_response_received_endpoints,
|
||||
on_response_received_endpoints_memo,
|
||||
on_response_received_commands: data.onResponseReceivedCommands && Parser.parseRR(data.onResponseReceivedCommands) || null,
|
||||
on_response_received_commands,
|
||||
on_response_received_commands_memo,
|
||||
/** @type {*} */
|
||||
continuation_contents: data.continuationContents && Parser.parseLC(data.continuationContents) || null,
|
||||
metadata: Parser.parse(data.metadata),
|
||||
|
||||
@@ -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