Skip to content

Commit 8dd349b

Browse files
Daniel MekuriaDaniel Mekuria
authored andcommitted
Add periodic progress refresh to show completion status on cards
1 parent 2d101d4 commit 8dd349b

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎src/client/components/cardgroup.jsx‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,23 @@ export default function CardGroup({
9090
};
9191
window.addEventListener('focus', handleFocus);
9292

93+
// Refresh progress when component becomes visible (user navigates back to dashboard)
94+
const handleVisibilityChange = () => {
95+
if (!document.hidden) {
96+
fetchProgress();
97+
}
98+
};
99+
document.addEventListener('visibilitychange', handleVisibilityChange);
100+
101+
// Refresh progress periodically (every 5 seconds) when on dashboard
102+
const interval = setInterval(() => {
103+
fetchProgress();
104+
}, 5000);
105+
93106
return () => {
94107
window.removeEventListener('focus', handleFocus);
108+
document.removeEventListener('visibilitychange', handleVisibilityChange);
109+
clearInterval(interval);
95110
};
96111
}, [isAuthenticated, topicKey]);
97112

0 commit comments

Comments
 (0)