From c2f15403dd4b141c5d80f9b44c85b9357e3d9095 Mon Sep 17 00:00:00 2001 From: Josh Patra <30350506+SoPat712@users.noreply.github.com> Date: Sun, 20 Apr 2025 13:37:21 -0400 Subject: [PATCH] Removed dependency, attempted fix --- package.json | 5 ++--- src/lib/HeardleGame.svelte | 30 ++++++++++++++---------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 11d8430..800e66c 100644 --- a/package.json +++ b/package.json @@ -29,14 +29,13 @@ "prettier-plugin-tailwindcss": "^0.6.11", "svelte": "^5.0.0", "svelte-check": "^4.0.0", - "svelte-hero-icons": "^5.2.0", "tailwindcss": "^4.0.0", "typescript": "^5.0.0", "typescript-eslint": "^8.20.0", "vite": "^6.2.5" }, "dependencies": { - "@tarekraafat/autocomplete.js": "^10.2.9", - "moment": "^2.30.1" + "moment": "^2.30.1", + "svelte-hero-icons": "^5.2.0" } } diff --git a/src/lib/HeardleGame.svelte b/src/lib/HeardleGame.svelte index 1d6a86c..d25d9ea 100644 --- a/src/lib/HeardleGame.svelte +++ b/src/lib/HeardleGame.svelte @@ -232,23 +232,21 @@ countdownInterval = setInterval(updateTime, 1000); widget = SC.Widget(iframeElement); - // wait for full page load (or you could just use setTimeout) - window.addEventListener('load', () => { - widget.bind(SC.Widget.Events.READY, () => { - widget.getDuration((d: number) => (fullDuration = d)); - widget.getCurrentSound((sound: any) => { - artworkUrl = sound.artwork_url || ''; - }); - - // give SC widget 2s to settle on Netlify before probing - setTimeout(() => { - widget.play(); - widget.pause(); - widget.seekTo(0); - loading = false; - widgetReady = true; - }, 2000); + widget.bind(SC.Widget.Events.READY, () => { + // grab duration & artwork + widget.getDuration((d: number) => (fullDuration = d)); + widget.getCurrentSound((sound: any) => { + artworkUrl = sound.artwork_url || ''; }); + + // small delay for Netlify, then probe the player + setTimeout(() => { + widget.play(); + widget.pause(); + widget.seekTo(0); + loading = false; + widgetReady = true; + }, 1000); }); widget.bind(SC.Widget.Events.PLAY, () => {