Skip to content

Commit

Permalink
fix(Search): Fix it occasionally returning only a small number of res…
Browse files Browse the repository at this point in the history
…ults (#720)
  • Loading branch information
absidue authored Aug 3, 2024
1 parent 4f5635a commit 2c0bb23
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/parser/youtube/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 2c0bb23

Please sign in to comment.