removed debounce since its using cached events

This commit is contained in:
chark1es 2025-02-13 03:13:38 -08:00
parent f62a3337a8
commit 6748434fd7

View file

@ -1187,27 +1187,22 @@ declare global {
fetchEvents(); fetchEvents();
}); });
// Search input with optimized debounce // Search input with instant search (no debounce needed for cached data)
let searchTimeout: number | undefined;
const searchInput = document.getElementById("searchInput"); const searchInput = document.getElementById("searchInput");
if (searchInput) { if (searchInput) {
// Add input event // Add input event for instant search
searchInput.addEventListener("input", (e) => { searchInput.addEventListener("input", (e) => {
const target = e.target as HTMLInputElement; const target = e.target as HTMLInputElement;
clearTimeout(searchTimeout); searchQuery = target.value.trim();
searchTimeout = window.setTimeout(() => { currentPage = 1;
searchQuery = target.value.trim(); fetchEvents();
currentPage = 1;
fetchEvents();
}, 150); // Reduced to 150ms for faster response
}); });
// Add keydown event for Enter key // Clear search on Escape key
searchInput.addEventListener("keydown", (e) => { searchInput.addEventListener("keydown", (e) => {
if (e.key === "Enter") { if (e.key === "Escape") {
clearTimeout(searchTimeout); (e.target as HTMLInputElement).value = "";
const target = e.target as HTMLInputElement; searchQuery = "";
searchQuery = target.value.trim();
currentPage = 1; currentPage = 1;
fetchEvents(); fetchEvents();
} }