mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 04:21:35 +00:00
fix(Search): Fix it occasionally returning only a small number of results (#720)
This commit is contained in:
@@ -8,13 +8,15 @@ import SearchSubMenu from '../classes/SearchSubMenu.js';
|
||||
import SectionList from '../classes/SectionList.js';
|
||||
import UniversalWatchCard from '../classes/UniversalWatchCard.js';
|
||||
|
||||
import { observe } from '../helpers.js';
|
||||
|
||||
import type { ApiResponse, Actions } from '../../core/index.js';
|
||||
import type { ObservedArray, YTNode } from '../helpers.js';
|
||||
import type { ISearchResponse } from '../types/index.js';
|
||||
|
||||
export default class Search extends Feed<ISearchResponse> {
|
||||
header?: SearchHeader;
|
||||
results?: ObservedArray<YTNode> | null;
|
||||
results: ObservedArray<YTNode>;
|
||||
refinements: string[];
|
||||
estimated_results: number;
|
||||
sub_menu?: SearchSubMenu;
|
||||
@@ -34,9 +36,7 @@ export default class Search extends Feed<ISearchResponse> {
|
||||
if (this.page.header)
|
||||
this.header = this.page.header.item().as(SearchHeader);
|
||||
|
||||
this.results = contents.find(
|
||||
(content) => content.is(ItemSection) && (content.contents && content.contents.length > 0)
|
||||
)?.as(ItemSection)?.contents;
|
||||
this.results = observe(contents.filterType(ItemSection).flatMap((section) => section.contents));
|
||||
|
||||
this.refinements = this.page.refinements || [];
|
||||
this.estimated_results = this.page.estimated_results || 0;
|
||||
|
||||
Reference in New Issue
Block a user