Skip to content

Commit 0465566

Browse files
feat: add message for game live stream delay
1 parent 7e518fd commit 0465566

3 files changed

Lines changed: 26 additions & 4 deletions

File tree

src/components/Common/DelayedLoading.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ interface DelayedLoadingProps {
66
isLoading: boolean
77
transparent?: boolean
88
delay?: number
9+
message?: React.ReactNode
910
children: React.ReactNode
1011
}
1112

1213
export const DelayedLoading: React.FC<DelayedLoadingProps> = ({
1314
isLoading,
1415
transparent = false,
1516
delay = 1000,
17+
message,
1618
children,
1719
}) => {
1820
const [showLoading, setShowLoading] = useState(false)
@@ -46,7 +48,7 @@ export const DelayedLoading: React.FC<DelayedLoadingProps> = ({
4648
transition={{ duration: 0.3 }}
4749
className="my-auto"
4850
>
49-
<Loading transparent={transparent} />
51+
<Loading transparent={transparent} message={message} />
5052
</motion.div>
5153
) : !isLoading ? (
5254
<motion.div

src/components/Common/Loading.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ const states = [
1414

1515
interface LoadingProps {
1616
transparent?: boolean
17+
message?: React.ReactNode
1718
}
1819

19-
export const Loading: React.FC<LoadingProps> = ({ transparent = false }) => {
20+
export const Loading: React.FC<LoadingProps> = ({
21+
transparent = false,
22+
message,
23+
}) => {
2024
const [currentIndex, setCurrentIndex] = useState(0)
2125
const [renderKey, setRenderKey] = useState(0)
2226

@@ -65,6 +69,11 @@ export const Loading: React.FC<LoadingProps> = ({ transparent = false }) => {
6569
</div>
6670
</div>
6771
<h2 className="text-2xl font-semibold">Loading...</h2>
72+
{message ? (
73+
<p className="max-w-prose px-4 text-center text-secondary">
74+
{message}
75+
</p>
76+
) : null}
6877
</div>
6978
</div>
7079
)

src/pages/analysis/stream/[gameId].tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,19 @@ const StreamAnalysisPage: NextPage = () => {
188188
streamController.game &&
189189
!streamController.streamState.gameEnded ? (
190190
<div className="absolute left-0 top-0 z-50">
191-
<DelayedLoading transparent isLoading={true}>
192-
<p>Loading...</p>
191+
<DelayedLoading
192+
transparent
193+
isLoading={true}
194+
message={
195+
<>
196+
Connecting to Lichess game {gameId}...
197+
<br />
198+
Lichess intentionally adds a short delay to live move data to
199+
reduce engine-assisted cheating. The stream will start soon.
200+
</>
201+
}
202+
>
203+
<></>
193204
</DelayedLoading>
194205
</div>
195206
) : null}

0 commit comments

Comments
 (0)