From 01c5322b65cbb85720ffd68dbf1625306cdc3899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20H=C3=A1la?= Date: Sun, 10 Nov 2024 20:42:54 +0100 Subject: [PATCH] Remove debounce from search - Perf problems seems to be gone already --- backend/templates/songs/index.html | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/backend/templates/songs/index.html b/backend/templates/songs/index.html index db88730..461f6cc 100644 --- a/backend/templates/songs/index.html +++ b/backend/templates/songs/index.html @@ -122,17 +122,6 @@
<%:author%>
import {Options, BooleanOption} from "{% static 'js/Options.js' %}" const canWakeLock = () => 'wakeLock' in navigator; - function debounce(callback, delay = 1000) { - var time; - - return (...args) => { - clearTimeout(time); - time = setTimeout(() => { - callback(...args); - }, delay); - }; - } - let table = null function createDatatable(paging, initialSearch) { const options = { @@ -259,13 +248,6 @@
<%:author%>
$(".chord").show() } } - const search = debounce( - function ( val ) { - table.search(val); - table.draw(false); - console.log("searched") - }, 200 - ); const config = new Map([ ["hide_chords", new BooleanOption(document.getElementById("hideChords"), hideChords, false)], @@ -322,7 +304,8 @@
<%:author%>
}); document.getElementById("searchInput").addEventListener("input", function(event) { - search(event.target.value) + table.search(event.target.value); + table.draw(false); }) {% endblock %} \ No newline at end of file