Add grocery-lists

This commit is contained in:
dvirlabs 2025-12-11 16:03:06 +02:00
parent df7510da2e
commit 080977cdb7
2 changed files with 10 additions and 1 deletions

View File

@ -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);
}
};

View File

@ -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");
}