From a8afe8015305e5ac32d1bf5034f74515af929c15 Mon Sep 17 00:00:00 2001 From: Phil Date: Fri, 16 Sep 2022 14:26:36 +0100 Subject: [PATCH] Fixed unnecessary relinking Twitch account when logging in on Twitch page. --- web/lib/twitch/link-twitch-account.ts | 1 + web/pages/twitch.tsx | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/web/lib/twitch/link-twitch-account.ts b/web/lib/twitch/link-twitch-account.ts index c9c704eb..f36a03b3 100644 --- a/web/lib/twitch/link-twitch-account.ts +++ b/web/lib/twitch/link-twitch-account.ts @@ -42,6 +42,7 @@ export async function linkTwitchAccountRedirect( const [twitchAuthURL] = await initLinkTwitchAccount(user.id, apiKey) window.location.href = twitchAuthURL + await new Promise((r) => setTimeout(r, 1e10)) // Wait "forever" for the page to change location } export async function updateBotEnabledForUser( diff --git a/web/pages/twitch.tsx b/web/pages/twitch.tsx index 158d8e20..49b004fa 100644 --- a/web/pages/twitch.tsx +++ b/web/pages/twitch.tsx @@ -51,6 +51,8 @@ function ButtonGetStarted(props: { const { user, privateUser } = await getUserAndPrivateUser(userId) if (!user || !privateUser) return + if (privateUser.twitchInfo?.twitchName) return // If we've already linked Twitch, no need to do so again + await linkTwitchAccountRedirect(user, privateUser) } @@ -64,6 +66,7 @@ function ButtonGetStarted(props: { } catch (e) { console.error(e) toast.error('Failed to sign up. Please try again later.') + } finally { setLoading(false) } } @@ -347,7 +350,9 @@ function SetUpBot(props: {
} + overrideButton={ + twitchLinked && + } > Use the button above to add the bot to your channel. Then mod it by typing in your Twitch chat: /mod ManifoldBot @@ -399,7 +404,7 @@ export default function TwitchLandingPage() { - + )