Browse Source

Debounces event handler for graph search

main
Keith Daulton 2 years ago
parent
commit
333758c35d
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      src/webviews/apps/plus/graph/GraphWrapper.tsx

+ 3
- 2
src/webviews/apps/plus/graph/GraphWrapper.tsx View File

@ -26,6 +26,7 @@ import type {
} from '../../../../plus/webviews/graph/protocol';
import type { Subscription } from '../../../../subscription';
import { getSubscriptionTimeRemaining, SubscriptionState } from '../../../../subscription';
import { debounce } from '../../../../system/function';
import { pluralize } from '../../../../system/string';
import { SearchField, SearchNav } from '../../shared/components/search/react';
import type { DateTimeFormat } from '../../shared/date';
@ -347,7 +348,7 @@ export function GraphWrapper({
}
};
const handleSearchInput = (e: CustomEvent<SearchQuery>) => {
const handleSearchInput = debounce((e: CustomEvent<SearchQuery>) => {
const detail = e.detail;
setSearchQuery(detail);
@ -357,7 +358,7 @@ export function GraphWrapper({
setSearchResultIds(undefined);
}
onSearchCommits?.(isValid ? detail : undefined);
};
}, 250);
useLayoutEffect(() => {
if (mainRef.current === null) return;

Loading…
Cancel
Save