From 43d40e5735d44c62b41fe44d79afe96623bc98f0 Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Fri, 13 Feb 2026 13:41:55 +0100 Subject: [PATCH] fix: add loading delay for notifications fetching in NotificationCenter to improve user experience --- components/notifications/NotificationCenter.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/notifications/NotificationCenter.tsx b/components/notifications/NotificationCenter.tsx index 5f66a37..5837543 100644 --- a/components/notifications/NotificationCenter.tsx +++ b/components/notifications/NotificationCenter.tsx @@ -52,6 +52,8 @@ function getTypeIcon(type: string) { return } +const LOADING_DELAY_MS = 250 + export default function NotificationCenter() { const [open, setOpen] = useState(false) const [notifications, setNotifications] = useState([]) @@ -61,8 +63,8 @@ export default function NotificationCenter() { const dropdownRef = useRef(null) const fetchNotifications = async () => { - setLoading(true) setError(null) + const loadingTimer = setTimeout(() => setLoading(true), LOADING_DELAY_MS) try { const res = await listNotifications() setNotifications(Array.isArray(res?.notifications) ? res.notifications : []) @@ -72,6 +74,7 @@ export default function NotificationCenter() { setNotifications([]) setUnreadCount(0) } finally { + clearTimeout(loadingTimer) setLoading(false) } }