feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes
This commit is contained in:
parent
01ef3293cf
commit
66b6b45ba9
399 changed files with 17828 additions and 11330 deletions
|
|
@ -1,7 +1,7 @@
|
|||
'use client'
|
||||
|
||||
import Link from 'next/link'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { Alert, Box, Button, CircularProgress, Typography } from '@mui/material'
|
||||
import {
|
||||
ArrowUpRight,
|
||||
|
|
@ -73,12 +73,25 @@ function formatDuration(seconds: number): string {
|
|||
|
||||
export default function DashboardPage(): React.ReactElement {
|
||||
const { user, loading: authLoading } = useAuth()
|
||||
const userId = user?.id
|
||||
const [snapshot, setSnapshot] = useState<DashboardSnapshot | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const mountedRef = useRef(true)
|
||||
const requestSeqRef = useRef(0)
|
||||
|
||||
useEffect(() => {
|
||||
mountedRef.current = true
|
||||
return () => {
|
||||
mountedRef.current = false
|
||||
}
|
||||
}, [])
|
||||
|
||||
const load = useCallback(async (): Promise<void> => {
|
||||
if (!user) {
|
||||
const seq = ++requestSeqRef.current
|
||||
const isStale = (): boolean => !mountedRef.current || requestSeqRef.current !== seq
|
||||
|
||||
if (!userId) {
|
||||
if (!authLoading) {
|
||||
setSnapshot(null)
|
||||
setError('세션이 만료되었습니다. 다시 로그인해 주세요.')
|
||||
|
|
@ -90,14 +103,19 @@ export default function DashboardPage(): React.ReactElement {
|
|||
setError(null)
|
||||
try {
|
||||
const client = getSupabaseBrowserClient() as unknown as D3roSupabaseClient
|
||||
setSnapshot(await loadDashboardSnapshot(client, user.id))
|
||||
const nextSnapshot = await loadDashboardSnapshot(client, userId)
|
||||
if (isStale()) return
|
||||
setSnapshot(nextSnapshot)
|
||||
} catch (requestError) {
|
||||
if (isStale()) return
|
||||
setSnapshot(null)
|
||||
setError(dashboardMessage(requestError))
|
||||
} finally {
|
||||
setLoading(false)
|
||||
if (!isStale()) {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
}, [authLoading, user])
|
||||
}, [authLoading, userId])
|
||||
|
||||
useEffect(() => {
|
||||
void load()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue