Browse Source

refac: placeholder performance

Timothy Jaeryang Baek 2 months ago
parent
commit
d9ee53b504
1 changed files with 12 additions and 8 deletions
  1. 12 8
      src/lib/components/chat/Suggestions.svelte

+ 12 - 8
src/lib/components/chat/Suggestions.svelte

@@ -42,14 +42,18 @@
 	}
 
 	const getFilteredPrompts = (inputValue) => {
-		const newFilteredPrompts = inputValue.trim()
-			? fuse.search(inputValue.trim()).map((result) => result.item)
-			: sortedPrompts;
-
-		// Compare with the oldFilteredPrompts
-		// If there's a difference, update array + version
-		if (!arraysEqual(filteredPrompts, newFilteredPrompts)) {
-			filteredPrompts = newFilteredPrompts;
+		if (inputValue.length > 500) {
+			filteredPrompts = [];
+		} else {
+			const newFilteredPrompts = inputValue.trim()
+				? fuse.search(inputValue.trim()).map((result) => result.item)
+				: sortedPrompts;
+
+			// Compare with the oldFilteredPrompts
+			// If there's a difference, update array + version
+			if (!arraysEqual(filteredPrompts, newFilteredPrompts)) {
+				filteredPrompts = newFilteredPrompts;
+			}
 		}
 	};