diff --git a/common/user.ts b/common/user.ts index b490ab0c..5ab07d35 100644 --- a/common/user.ts +++ b/common/user.ts @@ -71,6 +71,7 @@ export type PrivateUser = { twitchName: string controlToken: string botEnabled?: boolean + needsRelinking?: boolean } } diff --git a/web/components/profile/twitch-panel.tsx b/web/components/profile/twitch-panel.tsx deleted file mode 100644 index a37b21dc..00000000 --- a/web/components/profile/twitch-panel.tsx +++ /dev/null @@ -1,184 +0,0 @@ -import clsx from 'clsx' -import { MouseEventHandler, ReactNode, useState } from 'react' -import toast from 'react-hot-toast' - -import { LinkIcon } from '@heroicons/react/solid' -import { usePrivateUser, useUser } from 'web/hooks/use-user' -import { updatePrivateUser } from 'web/lib/firebase/users' -import { track } from 'web/lib/service/analytics' -import { - linkTwitchAccountRedirect, - updateBotEnabledForUser, -} from 'web/lib/twitch/link-twitch-account' -import { copyToClipboard } from 'web/lib/util/copy' -import { Button, ColorType } from './../button' -import { Row } from './../layout/row' -import { LoadingIndicator } from './../loading-indicator' -import { PrivateUser } from 'common/user' - -function BouncyButton(props: { - children: ReactNode - onClick?: MouseEventHandler - color?: ColorType - className?: string -}) { - const { children, onClick, color, className } = props - return ( - - ) -} - -function BotConnectButton(props: { - privateUser: PrivateUser | null | undefined -}) { - const { privateUser } = props - const [loading, setLoading] = useState(false) - - const updateBotConnected = (connected: boolean) => async () => { - if (!privateUser) return - const twitchInfo = privateUser.twitchInfo - if (!twitchInfo) return - - const error = connected - ? 'Failed to add bot to your channel' - : 'Failed to remove bot from your channel' - const success = connected - ? 'Added bot to your channel' - : 'Removed bot from your channel' - - setLoading(true) - toast.promise( - updateBotEnabledForUser(privateUser, connected).then(() => - updatePrivateUser(privateUser.id, { - twitchInfo: { ...twitchInfo, botEnabled: connected }, - }) - ), - { loading: 'Updating bot settings...', error, success } - ) - try { - } finally { - setLoading(false) - } - } - - return ( - <> - {privateUser?.twitchInfo?.botEnabled ? ( - - Remove bot from your channel - - ) : ( - - Add bot to your channel - - )} - - ) -} - -export function TwitchPanel() { - const user = useUser() - const privateUser = usePrivateUser() - - const twitchInfo = privateUser?.twitchInfo - const twitchName = twitchInfo?.twitchName - const twitchToken = twitchInfo?.controlToken - - const linkIcon =