From 11535b02dd1defe9c6ca5b3c0ea59d71038ec451 Mon Sep 17 00:00:00 2001 From: Govorunb Date: Tue, 11 Jun 2024 13:09:59 +1000 Subject: [PATCH] fix auth flow maybe --- frontend/www/src/modules/auth.ts | 6 +++++- frontend/www/src/modules/redeems.ts | 4 ---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/www/src/modules/auth.ts b/frontend/www/src/modules/auth.ts index 68a8b52..401ea1e 100644 --- a/frontend/www/src/modules/auth.ts +++ b/frontend/www/src/modules/auth.ts @@ -2,6 +2,7 @@ import { Transaction } from "common/types"; import { ebsFetch } from "../util/ebs"; import { hideProcessingModal, openModal, showErrorModal, showSuccessModal, transactionToken } from "./modal"; import { logToDiscord } from "../util/logger"; +import { renderRedeemButtons } from "./redeems"; const $loginPopup = document.getElementById("onboarding")!; const $loginButton = document.getElementById("twitch-login")!; @@ -9,7 +10,10 @@ const $loginButton = document.getElementById("twitch-login")!; document.addEventListener("DOMContentLoaded", () => ($loginButton.onclick = Twitch.ext.actions.requestIdShare)); Twitch.ext.onAuthorized(() => { - if (Twitch.ext.viewer.id) $loginPopup.style.display = "none"; + $loginPopup.style.display = Twitch.ext.viewer.id ? "none" : ""; + if (Twitch.ext.viewer.id) { + renderRedeemButtons().then(); + } }); Twitch.ext.bits.onTransactionComplete(async (transaction) => { diff --git a/frontend/www/src/modules/redeems.ts b/frontend/www/src/modules/redeems.ts index 7c4e4be..c282b32 100644 --- a/frontend/www/src/modules/redeems.ts +++ b/frontend/www/src/modules/redeems.ts @@ -5,10 +5,6 @@ const $mainContainer = document.getElementsByTagName("main")!; const $redeemContainer = document.getElementById("items")!; const $modalProcessing = document.getElementById("modal-processing")!; -document.addEventListener("DOMContentLoaded", () => { - renderRedeemButtons().then(); -}); - export async function renderRedeemButtons() { $redeemContainer.innerHTML = `

Loading content...

`;