modified: static/js/game.js

This commit is contained in:
SimolZimol
2026-08-07 22:46:59 +02:00
parent 62eebf75ca
commit 0ec62f9d2e

View File

@@ -76,6 +76,7 @@
// ---------- Suche / Autocomplete ----------
let searchTimer = null;
let searchSeq = 0;
let suggestions = [];
let selectedIndex = -1;
@@ -84,7 +85,10 @@
const q = searchInput.value.trim();
if (!q) { closeAutocomplete(); return; }
searchTimer = setTimeout(async () => {
const mySeq = ++searchSeq;
const res = await fetch(`/api/search?q=${encodeURIComponent(q)}`);
// Nur die aktuellste Anfrage uebernehmen (Race vermeiden)
if (mySeq !== searchSeq) return;
suggestions = await res.json();
renderAutocomplete();
}, 200);