Browse Source

refac: placeholder performance

Timothy Jaeryang Baek 2 tháng trước cách đây
mục cha
commit
d9ee53b504

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

@@ -42,14 +42,18 @@
 	}
 	}
 
 
 	const getFilteredPrompts = (inputValue) => {
 	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;
+			}
 		}
 		}
 	};
 	};