From ef2fae7ab282c85de9b88c3f9633b255b0950c01 Mon Sep 17 00:00:00 2001 From: Zyrenth Date: Mon, 10 Jun 2024 09:17:15 +0200 Subject: [PATCH] update for VedalAI/swarm-control#25 --- frontend/www/src/modules/auth.ts | 1 + frontend/www/src/modules/modal.ts | 7 +++++++ frontend/www/src/modules/redeems.ts | 8 ++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/www/src/modules/auth.ts b/frontend/www/src/modules/auth.ts index 9595288..06a0ad6 100644 --- a/frontend/www/src/modules/auth.ts +++ b/frontend/www/src/modules/auth.ts @@ -97,5 +97,6 @@ Twitch.ext.bits.onTransactionCancelled(async () => { ], }).then(); } + hideProcessingModal(); showErrorModal("Transaction cancelled.", `Transaction ID: ${transactionToken}`); }); diff --git a/frontend/www/src/modules/modal.ts b/frontend/www/src/modules/modal.ts index b77dafa..b30ee81 100644 --- a/frontend/www/src/modules/modal.ts +++ b/frontend/www/src/modules/modal.ts @@ -62,6 +62,13 @@ document.addEventListener("DOMContentLoaded", () => { e.preventDefault(); setCartArgsFromForm(e.target as HTMLFormElement); }; + + $modalWrapper.onclick = (e) => { + if (e.target !== $modalWrapper) return; + if ($modalProcessing.style.opacity == "1") return; + + closeModal(); + }; }); export async function openModal(redeem: Redeem | null) { diff --git a/frontend/www/src/modules/redeems.ts b/frontend/www/src/modules/redeems.ts index 0d1289a..e7daa3b 100644 --- a/frontend/www/src/modules/redeems.ts +++ b/frontend/www/src/modules/redeems.ts @@ -1,8 +1,9 @@ -import { openModal, showErrorModal } from "./modal"; +import { hideProcessingModal, openModal, showErrorModal } from "./modal"; import { getConfig } from "../util/config"; const $mainContainer = document.getElementsByTagName("main")!; const $redeemContainer = document.getElementById("items")!; +const $modalProcessing = document.getElementById("modal-processing")!; document.addEventListener("DOMContentLoaded", () => { renderRedeemButtons().then(); @@ -62,5 +63,8 @@ export async function renderRedeemButtons() { $redeemContainer.appendChild(item); } - showErrorModal("New update!", "The items have been updated, because of this you need to reopen this modal."); + if ($modalProcessing.style.opacity !== "1") { + hideProcessingModal(); + showErrorModal("New update!", "The items have been updated, because of this you need to reopen this modal."); + } }