Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix report dialog flashing error state on open (#10099)

authored by

Samuel Newman and committed by
GitHub
f08bf5fe 3e7e859c

+7 -8
+7 -8
src/components/hooks/useDelayedLoading.ts
··· 1 1 import {useEffect, useState} from 'react' 2 2 3 - export function useDelayedLoading(delay: number, initialState: boolean = true) { 4 - const [isLoading, setIsLoading] = useState(initialState) 3 + export function useDelayedLoading(delay: number, isActuallyLoading: boolean) { 4 + const [isDelayActive, setIsDelayActive] = useState(isActuallyLoading) 5 5 6 6 useEffect(() => { 7 - let timeout: NodeJS.Timeout 8 - // on initial load, show a loading spinner for a hot sec to prevent flash 9 - if (isLoading) timeout = setTimeout(() => setIsLoading(false), delay) 7 + if (!isDelayActive) return 10 8 11 - return () => timeout && clearTimeout(timeout) 12 - }, [isLoading, delay]) 9 + const timeout = setTimeout(() => setIsDelayActive(false), delay) 10 + return () => clearTimeout(timeout) 11 + }, [isDelayActive, delay]) 13 12 14 - return isLoading 13 + return isDelayActive || isActuallyLoading 15 14 }