chore: add jsdoc comments to selectFilter method

This commit is contained in:
LuanRT
2022-06-10 03:34:55 -03:00
parent 659df51115
commit afa39753d5

View File

@@ -1,7 +1,7 @@
'use strict';
const Parser = require('../contents');
const { InnertubeError } = require('../../utils/Utils');
const { InnertubeError, observe } = require('../../utils/Utils');
/** namespace **/
class VideoInfo {
@@ -116,15 +116,31 @@ class VideoInfo {
this.comments_entry_point_header = comments_entry_point?.contents.get({ type: 'commentsEntryPointHeaderRenderer' }) || {};
}
async selectFilter(chip) {
const response = await chip.endpoint.call(this.#actions);
/**
* Applies given filter to the watch next feed.
* @param {string} filter
* @returns {Promise.<VideoInfo>}
*/
async selectFilter(name) {
if (!this.filters.includes(name))
throw new InnertubeError('Invalid filter', { available_filters: this.filters });
const filter = this.related_chip_cloud.chips.get({ text: name });
if (filter.is_selected) return this;
const response = await filter.endpoint.call(this.#actions);
const data = response.on_response_received_endpoints.get({ target_id: 'watch-next-feed' });
this.watch_next_feed = data.continuation_items;
return this;
}
/** @type {string} */
get filters() {
return this.related_chip_cloud.chips.map((chip) => chip.text);
}
get page() {
return this.#page;
}