mirror of
				https://github.com/karl0ss/homepage.git
				synced 2025-11-04 00:10:57 +00:00 
			
		
		
		
	Fix: maybe prevent unnecessary search suggestion calls
This commit is contained in:
		
							parent
							
								
									48e0a0e8ef
								
							
						
					
					
						commit
						191a95c55c
					
				@ -129,7 +129,7 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
 | 
			
		||||
  useEffect(() => {
 | 
			
		||||
    const abortController = new AbortController();
 | 
			
		||||
 | 
			
		||||
    if (searchString.length === 0) setResults([]);
 | 
			
		||||
    if (searchString.trim().length === 0) setResults([]);
 | 
			
		||||
    else {
 | 
			
		||||
      let newResults = servicesAndBookmarks.filter((r) => {
 | 
			
		||||
        const nameMatch = r.name.toLowerCase().includes(searchString);
 | 
			
		||||
 | 
			
		||||
@ -94,6 +94,7 @@ export default function Search({ options }) {
 | 
			
		||||
    if (
 | 
			
		||||
      options.showSearchSuggestions &&
 | 
			
		||||
      (selectedProvider.suggestionUrl || options.suggestionUrl) && // custom providers pass url via options
 | 
			
		||||
      query.trim().length > 0 &&
 | 
			
		||||
      query.trim() !== searchSuggestions[0]
 | 
			
		||||
    ) {
 | 
			
		||||
      fetch(`/api/search/searchSuggestion?query=${encodeURIComponent(query)}&providerName=${selectedProvider.name}`, {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user