From e1911ab53501bbb0421864e9130795fdbc4972dd Mon Sep 17 00:00:00 2001 From: Dang3rZone <73022360+Dang3rZone@users.noreply.github.com> Date: Sun, 22 Nov 2026 09:35:05 +0100 Subject: [PATCH] Clear all in the notification bell panel The bell panel could only remove notifications one at a time, while update notices pile up between visits. It now has the Notifications screen's Clear all next to Close, shown while there is anything to clear. --- client/e2e/notifications.spec.ts | 23 ++++++++++++++ client/src/layout/NotificationInbox.tsx | 40 +++++++++++++++++-------- 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/client/e2e/notifications.spec.ts b/client/e2e/notifications.spec.ts index 9e5e1b1cf..c541f66a0 100644 --- a/client/e2e/notifications.spec.ts +++ b/client/e2e/notifications.spec.ts @@ -95,3 +95,26 @@ for (const [name, width, height] of [ await main.getByRole("tab", { name: /Settings/ }).click(); await expect(main.getByText("7 days")).toBeVisible(); }); + +test("Clear all in the bell panel empties the list the Notifications screen shows", async ({ page }) => { + await page.setViewportSize({ width: 1280, height: 800 }); + await seed(page); + await page.goto("/", { waitUntil: "domcontentloaded" }); + + const bell = page.getByRole("button", { name: "Open notifications" }).locator("visible=true"); + await expect(bell).toHaveCount(1, { timeout: 30_000 }); + await bell.click(); + const panel = page.getByTestId("notifications-panel").locator("visible=true"); + await expect(panel.getByRole("listitem")).toHaveCount(8); + + // All twelve go, not only the eight the panel shows; with nothing left the button goes too. + await panel.getByRole("button", { name: "Clear all" }).click(); + await expect(panel.getByRole("listitem")).toHaveCount(0); + await expect(panel.getByText(/No notifications yet/)).toBeVisible(); + await expect(panel.getByRole("button", { name: "Clear all" })).toHaveCount(0); + await expect(bell.getByTestId("notifications-badge")).toHaveCount(0); + + await panel.getByRole("button", { name: "See all" }).click(); + await expect(page).toHaveURL(/\/notifications$/); + await expect(page.getByRole("main").getByTestId("notifications-app-list").getByRole("listitem")).toHaveCount(0); +}); diff --git a/client/src/layout/NotificationInbox.tsx b/client/src/layout/NotificationInbox.tsx index ee3a17157..aa0fcea81 100644 --- a/client/src/layout/NotificationInbox.tsx +++ b/client/src/layout/NotificationInbox.tsx @@ -1,6 +1,6 @@ import { useEffect, useRef, useState } from "react"; import { useNavigate } from "react-router"; -import { ArrowRight, Bell, Tv, X } from "lucide-react"; +import { ArrowRight, Bell, Trash2, Tv, X } from "lucide-react"; import { useNotificationsStore } from "../state/notifications"; import { useTr } from "../state/lang"; @@ -75,6 +75,7 @@ export default function NotificationInbox({ const entries = useNotificationsStore((s) => s.entries); const markRead = useNotificationsStore((s) => s.markRead); const remove = useNotificationsStore((s) => s.remove); + const clear = useNotificationsStore((s) => s.clear); const [open, setOpen] = useState(false); const wrapperRef = useRef(null); const triggerRef = useRef(null); @@ -160,18 +161,31 @@ export default function NotificationInbox({ {tr("notif_tab_app", undefined, "This app")} - +
+ {/* Every notice, as the screen's Clear all: update notices pile up between visits. */} + {entries.length > 0 && ( + + )} + +
{peek.length === 0 ? (