Harden bot, storage and web API

This commit is contained in:
Shinuwa 2026-06-30 17:25:00 +02:00
parent e974bc6660
commit 20624a5c9c
43 changed files with 1265 additions and 1012 deletions

View file

@ -41,9 +41,11 @@ const elements = {
heroQueueBtn: document.getElementById("heroQueueBtn"),
uploadSection: document.getElementById("uploadSection"),
queueSection: document.getElementById("queueSection"),
backHomeBtn: document.getElementById("backHomeBtn"),
};
let pollIntervalId = null;
let refreshPromise = null;
const { setStatus, clearStatus } = createStatusManager(elements.status);
const apiFetch = createApiClient({
@ -51,7 +53,18 @@ const apiFetch = createApiClient({
getApiKey: () => state.apiKey,
});
async function refreshAll({ silent = false } = {}) {
function refreshAll(options = {}) {
if (refreshPromise) {
return refreshPromise;
}
refreshPromise = performRefresh(options).finally(() => {
refreshPromise = null;
});
return refreshPromise;
}
async function performRefresh({ silent = false } = {}) {
if (!silent) {
clearStatus();
}
@ -293,6 +306,9 @@ function bindEvents() {
elements.heroQueueBtn?.addEventListener("click", () =>
elements.queueSection?.scrollIntoView({ behavior: "smooth" })
);
elements.backHomeBtn?.addEventListener("click", () => {
window.location.href = "/";
});
elements.playerButtons?.forEach((button) => {
button.addEventListener("click", async () => {