Fixed missing results, also above search bar now

This commit is contained in:
Josh Patra
2025-04-20 01:03:18 -04:00
parent 2468c4ef09
commit 6ec5e584ab

View File

@@ -241,10 +241,6 @@
}); });
}); });
widget.bind(SC.Widget.Events.PLAY, () => { widget.bind(SC.Widget.Events.PLAY, () => {
// startPolling();
// if (!gameOver) {
// snippetTimeout = setTimeout(() => widget.pause(), segmentDurations[attemptCount]);
// }
startPolling(); startPolling();
if (!gameOver) { if (!gameOver) {
snippetTimeout = setTimeout(() => { snippetTimeout = setTimeout(() => {
@@ -261,9 +257,7 @@
stopAllTimers(); stopAllTimers();
}); });
widget.bind(SC.Widget.Events.PLAY_PROGRESS, (e: { currentPosition: number }) => { widget.bind(SC.Widget.Events.PLAY_PROGRESS, (e: { currentPosition: number }) => {
// only update while actually playing
if (!isPlaying) return; if (!isPlaying) return;
const limit = gameOver ? fullDuration : segmentDurations[attemptCount]; const limit = gameOver ? fullDuration : segmentDurations[attemptCount];
if (e.currentPosition >= limit) { if (e.currentPosition >= limit) {
currentPosition = limit; currentPosition = limit;
@@ -350,6 +344,11 @@
inputEl.blur(); inputEl.blur();
window.scrollTo({ top: 0, behavior: 'smooth' }); window.scrollTo({ top: 0, behavior: 'smooth' });
} }
// update suggestions reactively
$: suggestions = userInput
? tracks.filter((t) => t.title.toLowerCase().includes(userInput.toLowerCase())).slice(0, 5)
: [];
</script> </script>
<!-- How to Play Modal --> <!-- How to Play Modal -->
@@ -534,7 +533,7 @@
<!-- Guess & Skip/Submit --> <!-- Guess & Skip/Submit -->
{#if !gameOver} {#if !gameOver}
<div class="mb-4"> <div class="relative mb-4 overflow-visible">
<input <input
bind:this={inputEl} bind:this={inputEl}
type="text" type="text"
@@ -548,10 +547,11 @@
/> />
{#if suggestions.length} {#if suggestions.length}
<ul <ul
class="mt-1 max-h-36 overflow-y-auto rounded border" class="absolute bottom-full left-0 z-10 mb-1 max-h-36 w-full overflow-y-auto rounded border"
style="border-color:{darkMode ? COLORS.background : COLORS.text};background:{darkMode style="
? COLORS.text border-color: {darkMode ? COLORS.background : COLORS.text};
: COLORS.background}" background: {darkMode ? COLORS.text : COLORS.background}
"
> >
{#each suggestions as s} {#each suggestions as s}
<li> <li>