From 080977cdb712d666b917dfdba8432c2264f4f58a Mon Sep 17 00:00:00 2001 From: dvirlabs Date: Thu, 11 Dec 2025 16:03:06 +0200 Subject: [PATCH] Add grocery-lists --- frontend/src/components/NotificationBell.jsx | 8 +++++++- frontend/src/notificationApi.js | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/NotificationBell.jsx b/frontend/src/components/NotificationBell.jsx index f25cc29..7ab893f 100644 --- a/frontend/src/components/NotificationBell.jsx +++ b/frontend/src/components/NotificationBell.jsx @@ -41,7 +41,13 @@ function NotificationBell({ onShowToast }) { setNotifications(data); setUnreadCount(data.filter((n) => !n.is_read).length); } catch (error) { - // Silent fail for polling + // If unauthorized (401), user is not logged in - don't show errors + if (error.message.includes("401") || error.message.includes("Unauthorized") || error.message.includes("User not found")) { + setNotifications([]); + setUnreadCount(0); + return; + } + // Silent fail for other polling errors console.error("Failed to load notifications", error); } }; diff --git a/frontend/src/notificationApi.js b/frontend/src/notificationApi.js index 6ae055a..295ae86 100644 --- a/frontend/src/notificationApi.js +++ b/frontend/src/notificationApi.js @@ -16,6 +16,9 @@ export async function getNotifications(unreadOnly = false) { }); if (!response.ok) { + if (response.status === 401) { + throw new Error("Unauthorized"); + } const errorData = await response.json().catch(() => ({ detail: "Failed to fetch notifications" })); throw new Error(errorData.detail || "Failed to fetch notifications"); }