perf(web-player): cut down the searches the explore page fires
Typing in the search box navigated on every pause, so single letters and round-trips back to the same term each triggered a full YouTube search and a new grid of covers. The debounce is longer, a term identical to the current one no longer navigates, YouTube is only queried past a minimum length, and the infinite scroll waits until the sentinel is closer before pulling a page.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import LoaderCircle from '@lucide/svelte/icons/loader-circle';
|
||||
import { INFINITE_SCROLL_ROOT_MARGIN } from '$lib/config';
|
||||
|
||||
interface Props {
|
||||
onLoadMore: () => void;
|
||||
@@ -8,7 +9,7 @@
|
||||
rootMargin?: string;
|
||||
}
|
||||
|
||||
let { onLoadMore, hasMore, loading, rootMargin = '600px' }: Props = $props();
|
||||
let { onLoadMore, hasMore, loading, rootMargin = INFINITE_SCROLL_ROOT_MARGIN }: Props = $props();
|
||||
|
||||
let sentinel = $state<HTMLDivElement>();
|
||||
let visible = $state(false);
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
export const EXPLORE_PAGE_SIZE = 27;
|
||||
export const SEARCH_DEBOUNCE_MS = 450;
|
||||
export const SEARCH_MIN_LENGTH = 2;
|
||||
export const INFINITE_SCROLL_ROOT_MARGIN = '300px';
|
||||
export const HOME_LATEST_PAGE_SIZE = 12;
|
||||
export const YOUTUBE_FILLER_LIMIT = 27;
|
||||
|
||||
Reference in New Issue
Block a user