Skip to content

Commit

Permalink
Merge pull request #166 from dotabod/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Geczy authored Jan 5, 2025
2 parents a9c0481 + 93d7b64 commit d8353bf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/components/Dashboard/DisableToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ export function DisableToggle() {
}
}, [isDotabodDisabled, notification])

const botuser =
process.env.NEXT_PUBLIC_VERCEL_ENV === 'production'
? 'dotabod'
: 'dotabod_test'

useEffect(() => {
if (data?.banned) {
notification.open({
Expand All @@ -106,7 +111,7 @@ export function DisableToggle() {
type="link"
onClick={() => {
window.open(
`https://www.twitch.tv/popout/${user?.name}/viewercard/dotabod?popout=`,
`https://www.twitch.tv/popout/${user?.name}/viewercard/${botuser}?popout=`,
'mywindow',
'menubar=1,resizable=1,width=350,height=250'
)
Expand Down
16 changes: 15 additions & 1 deletion src/components/Overlay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Head from 'next/head'
import Image from 'next/image'
import { useEffect, useState } from 'react'

const OverlayPage = (props) => {
const OverlayPage = () => {
const [delayPassed, setDelayPassed] = useState(true)
const { notification } = App.useApp()

Expand Down Expand Up @@ -71,6 +71,15 @@ const OverlayPage = (props) => {

const [isInIframe, setIsInIframe] = useState(false)

// Refresh the page every 5 minutes if the socket is disconnected
useEffect(() => {
if (!connected) {
setTimeout(() => {
window.location.reload()
}, 300000)
}
}, [connected])

useEffect(() => {
if (!original) return

Expand Down Expand Up @@ -106,6 +115,11 @@ const OverlayPage = (props) => {
description:
'Dotabod is disabled until you go live on Twitch. Not streaming on Twitch? Type !online in your Twitch chat to enable Dotabod.',
})

// Refresh page every 5 minutes to check if stream is online
setTimeout(() => {
window.location.reload()
}, 300000)
} else {
notification.destroy('stream-offline')
}
Expand Down
4 changes: 1 addition & 3 deletions src/lib/hooks/useSocket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import {
EventSubChannelPredictionLockEvent,
EventSubChannelPredictionProgressEvent,
} from '@twurple/eventsub-base'
import { App } from 'antd'
import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'
import { useEffect } from 'react'
import { useDispatch } from 'react-redux'
import io, { type Socket } from 'socket.io-client'
import {
Expand Down Expand Up @@ -54,7 +53,6 @@ export const useSocket = ({
setWL,
setRadiantWinChance,
}) => {
const { notification } = App.useApp()
const router = useRouter()
const { userId } = router.query
const dispatch = useDispatch()
Expand Down

1 comment on commit d8353bf

@vercel
Copy link

@vercel vercel bot commented on d8353bf Jan 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.