fix: user connection song duration ui

This commit is contained in:
trisua 2025-06-26 13:46:37 -04:00
parent 87b61d7717
commit f622fb1125
2 changed files with 7 additions and 7 deletions

View file

@ -454,18 +454,18 @@ media_theme_pref();
} }
}); });
self.define("hooks::spotify_time_text", (_) => { self.define("hooks::spotify_time_text", async (_) => {
for (const element of Array.from( for (const element of Array.from(
document.querySelectorAll("[hook=spotify_time_text]") || [], document.querySelectorAll("[hook=spotify_time_text]") || [],
)) { )) {
function render() { async function render() {
const updated = element.getAttribute("hook-arg:updated"); const updated = element.getAttribute("hook-arg:updated");
const progress = element.getAttribute("hook-arg:progress"); const progress = element.getAttribute("hook-arg:progress");
const duration = element.getAttribute("hook-arg:duration"); const duration = element.getAttribute("hook-arg:duration");
const display = const display =
element.getAttribute("hook-arg:display") || "full"; element.getAttribute("hook-arg:display") || "full";
element.innerHTML = trigger("spotify::timestamp", [ element.innerHTML = await trigger("spotify::timestamp", [
updated, updated,
progress, progress,
duration, duration,
@ -473,7 +473,7 @@ media_theme_pref();
]); ]);
} }
setInterval(() => { setInterval(async () => {
element.setAttribute( element.setAttribute(
"hook-arg:updated", "hook-arg:updated",
Number.parseInt(element.getAttribute("hook-arg:updated")) + Number.parseInt(element.getAttribute("hook-arg:updated")) +
@ -486,10 +486,10 @@ media_theme_pref();
1000, 1000,
); );
render(); await render();
}, 1000); }, 1000);
render(); await render();
} }
}); });

View file

@ -1134,7 +1134,7 @@
artist: playing.artist.name, artist: playing.artist.name,
album: playing.album["#text"], album: playing.album["#text"],
// times // times
timestamp: new Date().getTime().toString(), timestamp: Date.now().toString(),
duration_ms: (mb_info.length || 0).toString(), duration_ms: (mb_info.length || 0).toString(),
}, },
}, },