Add diff spinner timeout (#660)
This commit is contained in:
committed by
GitHub
parent
2c8eb0ca21
commit
c79f0a200d
@@ -19,12 +19,31 @@ function DiffTab({ selectedAttempt }: DiffTabProps) {
|
||||
selectedAttempt?.id ?? null
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
}, [selectedAttempt?.id]);
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
}, [selectedAttempt?.id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (diffs.length > 0 && loading) {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [diffs, loading]);
|
||||
|
||||
// If no diffs arrive within 7 seconds, stop showing the spinner
|
||||
useEffect(() => {
|
||||
if (!loading) return;
|
||||
const timer = setTimeout(() => {
|
||||
if (diffs.length === 0) {
|
||||
setLoading(false);
|
||||
}
|
||||
}, 7000);
|
||||
return () => clearTimeout(timer);
|
||||
}, [loading, diffs.length]);
|
||||
|
||||
// Default-collapse certain change kinds on first load
|
||||
useEffect(() => {
|
||||
if (diffs.length === 0) return;
|
||||
@@ -76,6 +95,14 @@ function DiffTab({ selectedAttempt }: DiffTabProps) {
|
||||
);
|
||||
}
|
||||
|
||||
if (!loading && diffs.length === 0) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-full text-sm text-muted-foreground">
|
||||
No changes have been made yet
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<DiffTabContent
|
||||
diffs={diffs}
|
||||
|
||||
Reference in New Issue
Block a user