Add grocery-lists
This commit is contained in:
parent
df7510da2e
commit
080977cdb7
@ -41,7 +41,13 @@ function NotificationBell({ onShowToast }) {
|
|||||||
setNotifications(data);
|
setNotifications(data);
|
||||||
setUnreadCount(data.filter((n) => !n.is_read).length);
|
setUnreadCount(data.filter((n) => !n.is_read).length);
|
||||||
} catch (error) {
|
} 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);
|
console.error("Failed to load notifications", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -16,6 +16,9 @@ export async function getNotifications(unreadOnly = false) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
if (response.status === 401) {
|
||||||
|
throw new Error("Unauthorized");
|
||||||
|
}
|
||||||
const errorData = await response.json().catch(() => ({ detail: "Failed to fetch notifications" }));
|
const errorData = await response.json().catch(() => ({ detail: "Failed to fetch notifications" }));
|
||||||
throw new Error(errorData.detail || "Failed to fetch notifications");
|
throw new Error(errorData.detail || "Failed to fetch notifications");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user