From 86ddccf45e7d5ec1b53bd920eb39a63e882af916 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Tue, 14 Jul 2026 23:39:53 +0200 Subject: [PATCH] fix(ui): preserve notification sessions --- .../ui/src/host-callbacks/PromptPermission.ts | 1 + packages/ui/tests/notification.test.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/packages/ui/src/host-callbacks/PromptPermission.ts b/packages/ui/src/host-callbacks/PromptPermission.ts index 3c25d0fd..9b7012cb 100644 --- a/packages/ui/src/host-callbacks/PromptPermission.ts +++ b/packages/ui/src/host-callbacks/PromptPermission.ts @@ -9,6 +9,7 @@ import { getPermissionStatus, isDevicePermission, isEnforceableDevicePermission, + isDevicePermission, setPermissionStatus, type EnforceablePermissionName, } from "../permissions"; diff --git a/packages/ui/tests/notification.test.ts b/packages/ui/tests/notification.test.ts index 2093fa3f..e7c3002b 100644 --- a/packages/ui/tests/notification.test.ts +++ b/packages/ui/tests/notification.test.ts @@ -83,6 +83,22 @@ describe("notification host callbacks", () => { ).toEqual(["hello"]); }); + it("does not reload the product after granting notification permission", async () => { + await registerNotificationAuthorization(); + const reload = vi.fn(); + window.addEventListener("dotli:device-permission-changed", reload); + const { createPromptPermission } = + await import("@dotli/ui/host-callbacks/PromptPermission"); + + await expect( + createPromptPermission("myapp").devicePermission("Notifications"), + ).resolves.toEqual({ granted: true }); + await new Promise((resolve) => setTimeout(resolve, 0)); + + expect(reload).not.toHaveBeenCalled(); + window.removeEventListener("dotli:device-permission-changed", reload); + }); + it("reuses granted permission and cancels through the shared scheduler", async () => { await registerNotificationAuthorization("Authorized"); const { createNotificationAdapters } =