@peers-app/peers-ui 0.32.1 → 0.32.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/router.d.ts +1 -0
- package/dist/components/router.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/notifications/host-controls.d.ts +31 -0
- package/dist/notifications/host-controls.js +9 -0
- package/dist/notifications/index.d.ts +4 -0
- package/dist/notifications/index.js +20 -0
- package/dist/notifications/notification-bell.d.ts +6 -0
- package/dist/notifications/notification-bell.js +81 -0
- package/dist/notifications/notification-item.d.ts +7 -0
- package/dist/notifications/notification-item.js +43 -0
- package/dist/notifications/notifications-client.d.ts +47 -0
- package/dist/notifications/notifications-client.js +155 -0
- package/dist/notifications/notifications-screen.d.ts +2 -0
- package/dist/notifications/notifications-screen.js +209 -0
- package/dist/notifications/priority-alert.d.ts +5 -0
- package/dist/notifications/priority-alert.js +82 -0
- package/dist/root-layout/layouts/full-screen-layout.js +2 -1
- package/dist/root-layout/root-layout-host.js +2 -0
- package/dist/system-apps/index.d.ts +3 -0
- package/dist/system-apps/index.js +7 -3
- package/dist/system-apps/notifications.app.d.ts +3 -0
- package/dist/system-apps/notifications.app.js +9 -0
- package/dist/tabs-layout/network-status-indicator.js +2 -1
- package/package.json +3 -3
|
@@ -2,6 +2,7 @@ import "../screens/console-logs/console-logs-list";
|
|
|
2
2
|
import "../screens/identity";
|
|
3
3
|
import "../screens/network-viewer";
|
|
4
4
|
import "../screens/data-explorer";
|
|
5
|
+
import "../notifications";
|
|
5
6
|
/** Render the built-in or registered UI that owns a canonicalized route. */
|
|
6
7
|
export declare function Router({ path: providedPath }?: {
|
|
7
8
|
path?: string;
|
|
@@ -62,6 +62,7 @@ require("../screens/console-logs/console-logs-list");
|
|
|
62
62
|
require("../screens/identity");
|
|
63
63
|
require("../screens/network-viewer");
|
|
64
64
|
require("../screens/data-explorer");
|
|
65
|
+
require("../notifications");
|
|
65
66
|
/** Render the built-in or registered UI that owns a canonicalized route. */
|
|
66
67
|
function Router({ path: providedPath } = {}) {
|
|
67
68
|
// Hooks must run unconditionally (same order every render)
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./hooks";
|
|
|
13
13
|
export { openLink } from "./host-shell/host-shell-consumer";
|
|
14
14
|
export * from "./local-network/local-network-access";
|
|
15
15
|
export * from "./local-network/local-network-offer";
|
|
16
|
+
export { type INotificationHostControls, type NotificationHostState, notificationHostControls, } from "./notifications/host-controls";
|
|
16
17
|
export * from "./operator-console/operator-console";
|
|
17
18
|
export * from "./operator-console/operator-console-state";
|
|
18
19
|
export { type GlobalOverlay, globalOverlays, registerGlobalOverlay, unregisterGlobalOverlay, } from "./root-layout/global-overlays";
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.updateActiveTabTitle = exports.goToTabPath = exports.closeCurrentTab = exports.activeTabs = exports.activeTabId = exports.setRootLayout = exports.selectedRootLayoutId = exports.getRootLayouts = exports.getRootLayout = exports.DEFAULT_ROOT_LAYOUT_ID = exports.TabsLayoutApp = exports.RootLayoutHost = exports.LayoutPicker = exports.unregisterGlobalOverlay = exports.registerGlobalOverlay = exports.globalOverlays = exports.openLink = exports.mainContentPath = exports.isDesktop = exports.Typeahead = exports.MarkdownEditor = void 0;
|
|
17
|
+
exports.updateActiveTabTitle = exports.goToTabPath = exports.closeCurrentTab = exports.activeTabs = exports.activeTabId = exports.setRootLayout = exports.selectedRootLayoutId = exports.getRootLayouts = exports.getRootLayout = exports.DEFAULT_ROOT_LAYOUT_ID = exports.TabsLayoutApp = exports.RootLayoutHost = exports.LayoutPicker = exports.unregisterGlobalOverlay = exports.registerGlobalOverlay = exports.globalOverlays = exports.notificationHostControls = exports.openLink = exports.mainContentPath = exports.isDesktop = exports.Typeahead = exports.MarkdownEditor = void 0;
|
|
18
18
|
__exportStar(require("./components/data-grid"), exports);
|
|
19
19
|
__exportStar(require("./components/inverse-lazy-list"), exports);
|
|
20
20
|
var editor_1 = require("./components/markdown-editor/editor");
|
|
@@ -34,6 +34,8 @@ var host_shell_consumer_1 = require("./host-shell/host-shell-consumer");
|
|
|
34
34
|
Object.defineProperty(exports, "openLink", { enumerable: true, get: function () { return host_shell_consumer_1.openLink; } });
|
|
35
35
|
__exportStar(require("./local-network/local-network-access"), exports);
|
|
36
36
|
__exportStar(require("./local-network/local-network-offer"), exports);
|
|
37
|
+
var host_controls_1 = require("./notifications/host-controls");
|
|
38
|
+
Object.defineProperty(exports, "notificationHostControls", { enumerable: true, get: function () { return host_controls_1.notificationHostControls; } });
|
|
37
39
|
__exportStar(require("./operator-console/operator-console"), exports);
|
|
38
40
|
__exportStar(require("./operator-console/operator-console-state"), exports);
|
|
39
41
|
var global_overlays_1 = require("./root-layout/global-overlays");
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether this device can show the user's notifications outside the Peers window.
|
|
3
|
+
*
|
|
4
|
+
* - `unsupported`: the browser or host has no notification API.
|
|
5
|
+
* - `blocked`: the user denied permission; only the browser's site settings can undo that.
|
|
6
|
+
* - `off`: not enabled yet; `enable` asks for permission.
|
|
7
|
+
* - `on`: notifications show on this device; `disable` turns them off again.
|
|
8
|
+
*/
|
|
9
|
+
export type NotificationHostState = "unsupported" | "blocked" | "off" | "on";
|
|
10
|
+
/**
|
|
11
|
+
* What a host offers the Notifications settings screen for this device.
|
|
12
|
+
*
|
|
13
|
+
* The desktop app needs nothing here: its OS notifications need no permission. The PWA sets
|
|
14
|
+
* this so Settings can ask the browser for notification permission and subscribe to push.
|
|
15
|
+
*/
|
|
16
|
+
export interface INotificationHostControls {
|
|
17
|
+
state: NotificationHostState;
|
|
18
|
+
/** One line under the heading, for example what happens when the app is closed. */
|
|
19
|
+
description: string;
|
|
20
|
+
/** Something the user should know about the current state, such as how to unblock. */
|
|
21
|
+
detail?: string;
|
|
22
|
+
/** Turn notifications on for this device. Called from a click, so it may ask for permission. */
|
|
23
|
+
enable?: () => Promise<void>;
|
|
24
|
+
/** Turn them off again. */
|
|
25
|
+
disable?: () => Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The host's per-device notification controls, shown in Notifications → Settings under "This
|
|
29
|
+
* device" when set. A host that has none leaves it `undefined`.
|
|
30
|
+
*/
|
|
31
|
+
export declare const notificationHostControls: import("@peers-app/peers-sdk").Observable<INotificationHostControls | undefined>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.notificationHostControls = void 0;
|
|
4
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
5
|
+
/**
|
|
6
|
+
* The host's per-device notification controls, shown in Notifications → Settings under "This
|
|
7
|
+
* device" when set. A host that has none leaves it `undefined`.
|
|
8
|
+
*/
|
|
9
|
+
exports.notificationHostControls = (0, peers_sdk_1.observable)(undefined);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useNotificationSummary = exports.openNotificationById = exports.openNotification = exports.notificationsContract = exports.NOTIFICATIONS_PATH = exports.NotificationBell = void 0;
|
|
4
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
5
|
+
const notifications_client_1 = require("./notifications-client");
|
|
6
|
+
require("./notifications-screen");
|
|
7
|
+
require("./priority-alert");
|
|
8
|
+
var notification_bell_1 = require("./notification-bell");
|
|
9
|
+
Object.defineProperty(exports, "NotificationBell", { enumerable: true, get: function () { return notification_bell_1.NotificationBell; } });
|
|
10
|
+
var notifications_client_2 = require("./notifications-client");
|
|
11
|
+
Object.defineProperty(exports, "NOTIFICATIONS_PATH", { enumerable: true, get: function () { return notifications_client_2.NOTIFICATIONS_PATH; } });
|
|
12
|
+
Object.defineProperty(exports, "notificationsContract", { enumerable: true, get: function () { return notifications_client_2.notificationsContract; } });
|
|
13
|
+
Object.defineProperty(exports, "openNotification", { enumerable: true, get: function () { return notifications_client_2.openNotification; } });
|
|
14
|
+
Object.defineProperty(exports, "openNotificationById", { enumerable: true, get: function () { return notifications_client_2.openNotificationById; } });
|
|
15
|
+
Object.defineProperty(exports, "useNotificationSummary", { enumerable: true, get: function () { return notifications_client_2.useNotificationSummary; } });
|
|
16
|
+
// A notification clicked in the desktop app's main process opens what it's about here.
|
|
17
|
+
(0, peers_sdk_1.subscribe)("ui:openNotification", (event) => {
|
|
18
|
+
if (event.data?.notificationId)
|
|
19
|
+
void (0, notifications_client_1.openNotificationById)(event.data.notificationId);
|
|
20
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Group names by id, with "Personal" for the user's own context. */
|
|
2
|
+
export declare function useGroupNames(): Map<string, string>;
|
|
3
|
+
/** Bell with the notification badge, and a popover of active notifications. */
|
|
4
|
+
export declare function NotificationBell({ compact }: {
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useGroupNames = useGroupNames;
|
|
4
|
+
exports.NotificationBell = NotificationBell;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const tabs_state_1 = require("../tabs-layout/tabs-state");
|
|
9
|
+
const notification_item_1 = require("./notification-item");
|
|
10
|
+
const notifications_client_1 = require("./notifications-client");
|
|
11
|
+
/** Group names by id, with "Personal" for the user's own context. */
|
|
12
|
+
function useGroupNames() {
|
|
13
|
+
const [names, setNames] = (0, react_1.useState)(new Map());
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
let cancelled = false;
|
|
16
|
+
void (0, peers_sdk_1.getUserContext)().then(async (userContext) => {
|
|
17
|
+
const groups = await (0, peers_sdk_1.Groups)(userContext.userDataContext).list({});
|
|
18
|
+
const next = new Map(groups.map((group) => [group.groupId, group.name]));
|
|
19
|
+
next.set(userContext.userId, "Personal");
|
|
20
|
+
if (!cancelled)
|
|
21
|
+
setNames(next);
|
|
22
|
+
});
|
|
23
|
+
return () => {
|
|
24
|
+
cancelled = true;
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
return names;
|
|
28
|
+
}
|
|
29
|
+
/** Bell with the notification badge, and a popover of active notifications. */
|
|
30
|
+
function NotificationBell({ compact = false }) {
|
|
31
|
+
const summary = (0, notifications_client_1.useNotificationSummary)();
|
|
32
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
33
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
34
|
+
const popoverId = (0, react_1.useId)();
|
|
35
|
+
const { notifications, error } = (0, notifications_client_1.useNotifications)({ activeOnly: true, limit: 20 }, open);
|
|
36
|
+
const groupNames = useGroupNames();
|
|
37
|
+
(0, react_1.useEffect)(() => {
|
|
38
|
+
if (!open)
|
|
39
|
+
return;
|
|
40
|
+
const closeOutside = (event) => {
|
|
41
|
+
if (!containerRef.current?.contains(event.target))
|
|
42
|
+
setOpen(false);
|
|
43
|
+
};
|
|
44
|
+
const closeOnEscape = (event) => {
|
|
45
|
+
if (event.key === "Escape")
|
|
46
|
+
setOpen(false);
|
|
47
|
+
};
|
|
48
|
+
document.addEventListener("mousedown", closeOutside);
|
|
49
|
+
document.addEventListener("keydown", closeOnEscape);
|
|
50
|
+
return () => {
|
|
51
|
+
document.removeEventListener("mousedown", closeOutside);
|
|
52
|
+
document.removeEventListener("keydown", closeOnEscape);
|
|
53
|
+
};
|
|
54
|
+
}, [open]);
|
|
55
|
+
// Opening the list counts as seeing what's in it.
|
|
56
|
+
(0, react_1.useEffect)(() => {
|
|
57
|
+
if (!open || !notifications)
|
|
58
|
+
return;
|
|
59
|
+
const unseen = notifications.filter((n) => !n.seenAt).map((n) => n.notificationId);
|
|
60
|
+
if (unseen.length)
|
|
61
|
+
void (0, notifications_client_1.actOnNotifications)({ action: "seen", notificationIds: unseen });
|
|
62
|
+
}, [open, notifications]);
|
|
63
|
+
const label = summary.count
|
|
64
|
+
? `${summary.count} notification${summary.count === 1 ? "" : "s"}`
|
|
65
|
+
: summary.dot
|
|
66
|
+
? "New notifications"
|
|
67
|
+
: "Notifications";
|
|
68
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, className: "position-relative d-flex align-items-center", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm d-flex align-items-center px-2 text-body-secondary", style: {
|
|
69
|
+
border: "none",
|
|
70
|
+
background: "transparent",
|
|
71
|
+
minWidth: compact ? "30px" : undefined,
|
|
72
|
+
}, "aria-label": label, title: summary.paused ? `${label} (paused)` : label, "aria-expanded": open, "aria-controls": popoverId, "data-testid": "notification-bell", onClick: () => setOpen((current) => !current), children: (0, jsx_runtime_1.jsxs)("span", { className: "position-relative d-inline-flex", children: [(0, jsx_runtime_1.jsx)("i", { className: `bi ${summary.paused ? "bi-bell-slash" : summary.count || summary.dot ? "bi-bell-fill" : "bi-bell"}`, "aria-hidden": "true" }), summary.count > 0 ? ((0, jsx_runtime_1.jsx)("span", { className: "position-absolute badge rounded-pill bg-danger", style: {
|
|
73
|
+
fontSize: "0.55rem",
|
|
74
|
+
top: "-0.45rem",
|
|
75
|
+
right: "-0.7rem",
|
|
76
|
+
padding: "0.2em 0.4em",
|
|
77
|
+
}, "aria-hidden": "true", "data-testid": "notification-count", children: summary.count > 99 ? "99+" : summary.count })) : (summary.dot && ((0, jsx_runtime_1.jsx)("span", { className: "position-absolute rounded-circle bg-danger", style: { width: "0.45rem", height: "0.45rem", top: "-0.1rem", right: "-0.2rem" }, "aria-hidden": "true", "data-testid": "notification-dot" })))] }) }), open && ((0, jsx_runtime_1.jsxs)("div", { id: popoverId, role: "dialog", "aria-label": "Notifications", className: "position-absolute end-0 top-100 mt-1 bg-body border rounded shadow", style: { width: "min(22rem, calc(100vw - 2rem))", zIndex: 1080 }, children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center justify-content-between px-2 py-1 border-bottom", children: [(0, jsx_runtime_1.jsx)("strong", { className: "small", children: "Notifications" }), notifications && notifications.length > 0 && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-link p-0", onClick: () => void (0, notifications_client_1.actOnNotifications)({ action: "dismiss", all: true }), children: "Clear all" }))] }), (0, jsx_runtime_1.jsx)("div", { style: { maxHeight: "24rem", overflowY: "auto" }, children: error ? ((0, jsx_runtime_1.jsx)("output", { className: "small text-danger p-3", children: error })) : notifications === undefined ? ((0, jsx_runtime_1.jsx)("div", { className: "small text-body-secondary p-3", children: "Loading\u2026" })) : notifications.length === 0 ? ((0, jsx_runtime_1.jsx)("div", { className: "small text-body-secondary p-3", children: "You're all caught up." })) : (notifications.map((notification) => ((0, jsx_runtime_1.jsx)(notification_item_1.NotificationItem, { notification: notification, groupName: groupNames.get(notification.groupId), onOpened: () => setOpen(false) }, notification.notificationId)))) }), (0, jsx_runtime_1.jsx)("div", { className: "border-top px-2 py-1 text-end", children: (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-link p-0", onClick: () => {
|
|
78
|
+
setOpen(false);
|
|
79
|
+
(0, tabs_state_1.goToTabPath)(notifications_client_1.NOTIFICATIONS_PATH);
|
|
80
|
+
}, children: "History and settings" }) })] }))] }));
|
|
81
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { INotification } from "@peers-app/peers-sdk";
|
|
2
|
+
/** One notification row: open on click, with dismiss for active ones. */
|
|
3
|
+
export declare function NotificationItem({ notification, groupName, onOpened, }: {
|
|
4
|
+
notification: INotification;
|
|
5
|
+
groupName?: string;
|
|
6
|
+
onOpened?: () => void;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationItem = NotificationItem;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const notifications_client_1 = require("./notifications-client");
|
|
6
|
+
const levelIcons = {
|
|
7
|
+
priority: "bi-alarm-fill text-danger",
|
|
8
|
+
loud: "bi-bell-fill text-primary",
|
|
9
|
+
quiet: "bi-bell text-secondary",
|
|
10
|
+
background: "bi-dot text-secondary",
|
|
11
|
+
};
|
|
12
|
+
function handledLabel(notification) {
|
|
13
|
+
switch (notification.handledAs) {
|
|
14
|
+
case "acknowledged":
|
|
15
|
+
return "Acknowledged";
|
|
16
|
+
case "dismissed":
|
|
17
|
+
return "Dismissed";
|
|
18
|
+
case "opened":
|
|
19
|
+
return "Opened";
|
|
20
|
+
case "retracted":
|
|
21
|
+
return "No longer needed";
|
|
22
|
+
default:
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** One notification row: open on click, with dismiss for active ones. */
|
|
27
|
+
function NotificationItem({ notification, groupName, onOpened, }) {
|
|
28
|
+
const handled = handledLabel(notification);
|
|
29
|
+
const unseen = !notification.seenAt && !notification.handledAt;
|
|
30
|
+
const detail = [notification.fromName, groupName].filter(Boolean).join(" · ");
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `d-flex align-items-start gap-2 px-2 py-2 border-bottom ${handled ? "opacity-75" : ""}`, "data-notification-id": notification.notificationId, children: [(0, jsx_runtime_1.jsx)("i", { className: `bi ${levelIcons[notification.muted ? "background" : notification.level]} mt-1`, "aria-hidden": "true" }), (0, jsx_runtime_1.jsxs)("button", { type: "button", className: "btn btn-link text-start text-reset text-decoration-none p-0 flex-grow-1", style: { minWidth: 0 }, onClick: () => {
|
|
32
|
+
onOpened?.();
|
|
33
|
+
void (0, notifications_client_1.openNotification)(notification);
|
|
34
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { className: `text-truncate ${unseen ? "fw-semibold" : ""}`, children: notification.title }), notification.body && ((0, jsx_runtime_1.jsx)("div", { className: "small text-body-secondary", style: {
|
|
35
|
+
display: "-webkit-box",
|
|
36
|
+
WebkitLineClamp: 2,
|
|
37
|
+
WebkitBoxOrient: "vertical",
|
|
38
|
+
overflow: "hidden",
|
|
39
|
+
}, children: notification.body })), (0, jsx_runtime_1.jsx)("div", { className: "small text-body-secondary", children: [detail, handled, (0, notifications_client_1.timeAgo)(notification.createdAt)].filter(Boolean).join(" · ") })] }), !notification.handledAt && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-link text-body-secondary p-0", title: "Dismiss", "aria-label": `Dismiss ${notification.title}`, onClick: () => void (0, notifications_client_1.actOnNotifications)({
|
|
40
|
+
action: "dismiss",
|
|
41
|
+
notificationIds: [notification.notificationId],
|
|
42
|
+
}), children: (0, jsx_runtime_1.jsx)("i", { className: "bi bi-x-lg", "aria-hidden": "true" }) }))] }));
|
|
43
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type IActOnNotificationsInput, type IListNotificationsInput, type INotification, type INotificationSummary, type INotificationsConsumer } from "@peers-app/peers-sdk";
|
|
2
|
+
/** Shared handle for System Notifications on the local host; stable for `useHostContract`. */
|
|
3
|
+
export declare const notificationsContract: import("@peers-app/peers-sdk").IHostContractConsumer<INotificationsConsumer>;
|
|
4
|
+
/** Route of the Notifications system app. */
|
|
5
|
+
export declare const NOTIFICATIONS_PATH = "notifications";
|
|
6
|
+
/** Live badge and alert state from this device. */
|
|
7
|
+
export declare function useNotificationSummary(): INotificationSummary;
|
|
8
|
+
/** Notifications from `list`, reloaded whenever any notification changes. */
|
|
9
|
+
export declare function useNotifications(input: IListNotificationsInput, enabled?: boolean): {
|
|
10
|
+
notifications: {
|
|
11
|
+
title: string;
|
|
12
|
+
level: "priority" | "background" | "loud" | "quiet";
|
|
13
|
+
groupId: string;
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
notificationId: string;
|
|
16
|
+
requestedLevel: "priority" | "background" | "loud" | "quiet";
|
|
17
|
+
link?: string | undefined;
|
|
18
|
+
key?: string | undefined;
|
|
19
|
+
body?: string | undefined;
|
|
20
|
+
kind?: string | undefined;
|
|
21
|
+
expiresAt?: Date | undefined;
|
|
22
|
+
sourcePackageId?: string | undefined;
|
|
23
|
+
fromUserId?: string | undefined;
|
|
24
|
+
fromName?: string | undefined;
|
|
25
|
+
seenAt?: Date | undefined;
|
|
26
|
+
handledAt?: Date | undefined;
|
|
27
|
+
handledAs?: "opened" | "acknowledged" | "dismissed" | "retracted" | undefined;
|
|
28
|
+
snoozedUntil?: Date | undefined;
|
|
29
|
+
muted?: boolean | undefined;
|
|
30
|
+
}[] | undefined;
|
|
31
|
+
error: string | undefined;
|
|
32
|
+
summary: INotificationSummary;
|
|
33
|
+
};
|
|
34
|
+
/** List notifications, with dates revived from the transport. */
|
|
35
|
+
export declare function listNotifications(input: IListNotificationsInput): Promise<INotification[]>;
|
|
36
|
+
/** Act on notifications; errors are logged, not thrown. */
|
|
37
|
+
export declare function actOnNotifications(input: IActOnNotificationsInput): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Open what a notification is about: mark it opened, switch to its group, and go to its link.
|
|
40
|
+
*/
|
|
41
|
+
export declare function openNotification(notification: INotification): Promise<void>;
|
|
42
|
+
/** Finish a notification's group switch after the new group's routes and tabs have loaded. */
|
|
43
|
+
export declare function resumeNotificationNavigation(): Promise<void>;
|
|
44
|
+
/** Open a notification by id, as the desktop app does when its OS notification is clicked. */
|
|
45
|
+
export declare function openNotificationById(notificationId: string): Promise<void>;
|
|
46
|
+
/** Short relative time, such as "3m" or "2d". */
|
|
47
|
+
export declare function timeAgo(date: Date, now?: number): string;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NOTIFICATIONS_PATH = exports.notificationsContract = void 0;
|
|
4
|
+
exports.useNotificationSummary = useNotificationSummary;
|
|
5
|
+
exports.useNotifications = useNotifications;
|
|
6
|
+
exports.listNotifications = listNotifications;
|
|
7
|
+
exports.actOnNotifications = actOnNotifications;
|
|
8
|
+
exports.openNotification = openNotification;
|
|
9
|
+
exports.resumeNotificationNavigation = resumeNotificationNavigation;
|
|
10
|
+
exports.openNotificationById = openNotificationById;
|
|
11
|
+
exports.timeAgo = timeAgo;
|
|
12
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
const use_host_contract_1 = require("../hooks/use-host-contract");
|
|
15
|
+
const use_observable_1 = require("../hooks/use-observable");
|
|
16
|
+
const tabs_state_1 = require("../tabs-layout/tabs-state");
|
|
17
|
+
/** Shared handle for System Notifications on the local host; stable for `useHostContract`. */
|
|
18
|
+
exports.notificationsContract = (0, peers_sdk_1.hostContractConsumer)((0, peers_sdk_1.getNotificationsContractDefinition)());
|
|
19
|
+
/** Route of the Notifications system app. */
|
|
20
|
+
exports.NOTIFICATIONS_PATH = "notifications";
|
|
21
|
+
const pendingNavigationKey = "peers.notificationNavigation";
|
|
22
|
+
const emptySummary = {
|
|
23
|
+
count: 0,
|
|
24
|
+
dot: false,
|
|
25
|
+
active: 0,
|
|
26
|
+
ringing: [],
|
|
27
|
+
paused: false,
|
|
28
|
+
revision: 0,
|
|
29
|
+
};
|
|
30
|
+
/** Live badge and alert state from this device. */
|
|
31
|
+
function useNotificationSummary() {
|
|
32
|
+
const { consumer } = (0, use_host_contract_1.useHostContract)(exports.notificationsContract);
|
|
33
|
+
const [summary] = (0, use_observable_1.useObservable)(consumer?.observables.summary);
|
|
34
|
+
return summary ?? emptySummary;
|
|
35
|
+
}
|
|
36
|
+
/** Notifications from `list`, reloaded whenever any notification changes. */
|
|
37
|
+
function useNotifications(input, enabled = true) {
|
|
38
|
+
const summary = useNotificationSummary();
|
|
39
|
+
const [notifications, setNotifications] = (0, react_1.useState)();
|
|
40
|
+
const [error, setError] = (0, react_1.useState)();
|
|
41
|
+
const key = JSON.stringify(input);
|
|
42
|
+
// `key` stands for `input`; the revision reloads the list whenever a notification changes.
|
|
43
|
+
(0, react_1.useEffect)(() => {
|
|
44
|
+
if (!enabled)
|
|
45
|
+
return;
|
|
46
|
+
let cancelled = false;
|
|
47
|
+
void listNotifications(input)
|
|
48
|
+
.then((rows) => {
|
|
49
|
+
if (!cancelled) {
|
|
50
|
+
setNotifications(rows);
|
|
51
|
+
setError(undefined);
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
.catch((err) => {
|
|
55
|
+
if (!cancelled)
|
|
56
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
57
|
+
});
|
|
58
|
+
return () => {
|
|
59
|
+
cancelled = true;
|
|
60
|
+
};
|
|
61
|
+
}, [key, summary, enabled]);
|
|
62
|
+
return { notifications, error, summary };
|
|
63
|
+
}
|
|
64
|
+
/** List notifications, with dates revived from the transport. */
|
|
65
|
+
async function listNotifications(input) {
|
|
66
|
+
const consumer = await exports.notificationsContract.get();
|
|
67
|
+
const { notifications } = await consumer.tools.listNotifications(input);
|
|
68
|
+
return notifications.map(reviveDates);
|
|
69
|
+
}
|
|
70
|
+
/** Act on notifications; errors are logged, not thrown. */
|
|
71
|
+
async function actOnNotifications(input) {
|
|
72
|
+
try {
|
|
73
|
+
const consumer = await exports.notificationsContract.get();
|
|
74
|
+
await consumer.tools.actOnNotifications(input);
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
console.warn("[notifications] action failed", err);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const dateFields = ["createdAt", "expiresAt", "seenAt", "handledAt", "snoozedUntil"];
|
|
81
|
+
function reviveDates(row) {
|
|
82
|
+
const copy = { ...row };
|
|
83
|
+
for (const name of dateFields) {
|
|
84
|
+
const value = copy[name];
|
|
85
|
+
if (value !== undefined && value !== null && !(value instanceof Date)) {
|
|
86
|
+
copy[name] = new Date(value);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return copy;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Open what a notification is about: mark it opened, switch to its group, and go to its link.
|
|
93
|
+
*/
|
|
94
|
+
async function openNotification(notification) {
|
|
95
|
+
await actOnNotifications({ action: "open", notificationIds: [notification.notificationId] });
|
|
96
|
+
const userContext = await (0, peers_sdk_1.getUserContext)();
|
|
97
|
+
const target = notification.groupId;
|
|
98
|
+
const path = notification.link || exports.NOTIFICATIONS_PATH;
|
|
99
|
+
if ((userContext.currentlyActiveGroupId() || userContext.userId) !== target) {
|
|
100
|
+
// A group the user has left or disabled, from history: selecting it would create a context
|
|
101
|
+
// for it and keep it as the active group across restarts.
|
|
102
|
+
if (target !== userContext.userId && !userContext.groupIds().includes(target)) {
|
|
103
|
+
(0, tabs_state_1.goToTabPath)(exports.NOTIFICATIONS_PATH);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// Group switching reloads the renderer. Carry the destination through startup; navigating
|
|
107
|
+
// after a delay can lose the link or write it into the old group's tabs.
|
|
108
|
+
sessionStorage.setItem(pendingNavigationKey, JSON.stringify({ userId: userContext.userId, groupId: target, path }));
|
|
109
|
+
userContext.currentlyActiveGroupId(target);
|
|
110
|
+
await userContext.waitForActiveGroupPersistence();
|
|
111
|
+
await peers_sdk_1.rpcServerCalls.flushDatabases();
|
|
112
|
+
window.location.reload();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
(0, tabs_state_1.goToTabPath)(path);
|
|
116
|
+
}
|
|
117
|
+
/** Finish a notification's group switch after the new group's routes and tabs have loaded. */
|
|
118
|
+
async function resumeNotificationNavigation() {
|
|
119
|
+
const pending = sessionStorage.getItem(pendingNavigationKey);
|
|
120
|
+
if (!pending)
|
|
121
|
+
return;
|
|
122
|
+
sessionStorage.removeItem(pendingNavigationKey);
|
|
123
|
+
const userContext = await (0, peers_sdk_1.getUserContext)();
|
|
124
|
+
try {
|
|
125
|
+
const target = JSON.parse(pending);
|
|
126
|
+
if (target.userId === userContext.userId &&
|
|
127
|
+
target.groupId === (userContext.currentlyActiveGroupId() || userContext.userId) &&
|
|
128
|
+
typeof target.path === "string")
|
|
129
|
+
(0, tabs_state_1.goToTabPath)(target.path);
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
// A stale or malformed session value must not prevent the shell from starting.
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/** Open a notification by id, as the desktop app does when its OS notification is clicked. */
|
|
136
|
+
async function openNotificationById(notificationId) {
|
|
137
|
+
const [notification] = await listNotifications({ notificationIds: [notificationId], limit: 1 });
|
|
138
|
+
if (notification)
|
|
139
|
+
await openNotification(notification);
|
|
140
|
+
else
|
|
141
|
+
(0, tabs_state_1.goToTabPath)(exports.NOTIFICATIONS_PATH);
|
|
142
|
+
}
|
|
143
|
+
/** Short relative time, such as "3m" or "2d". */
|
|
144
|
+
function timeAgo(date, now = Date.now()) {
|
|
145
|
+
const seconds = Math.max(0, Math.round((now - date.getTime()) / 1000));
|
|
146
|
+
if (seconds < 60)
|
|
147
|
+
return "now";
|
|
148
|
+
const minutes = Math.round(seconds / 60);
|
|
149
|
+
if (minutes < 60)
|
|
150
|
+
return `${minutes}m`;
|
|
151
|
+
const hours = Math.round(minutes / 60);
|
|
152
|
+
if (hours < 24)
|
|
153
|
+
return `${hours}h`;
|
|
154
|
+
return `${Math.round(hours / 24)}d`;
|
|
155
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationsScreen = NotificationsScreen;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const use_observable_1 = require("../hooks/use-observable");
|
|
8
|
+
const ui_loader_1 = require("../ui-router/ui-loader");
|
|
9
|
+
const host_controls_1 = require("./host-controls");
|
|
10
|
+
const notification_bell_1 = require("./notification-bell");
|
|
11
|
+
const notification_item_1 = require("./notification-item");
|
|
12
|
+
const notifications_client_1 = require("./notifications-client");
|
|
13
|
+
const levelLabels = {
|
|
14
|
+
priority: "Priority: alarm until dealt with",
|
|
15
|
+
loud: "Loud: sound and popup",
|
|
16
|
+
quiet: "Quiet: no sound",
|
|
17
|
+
background: "Background: only in this list",
|
|
18
|
+
off: "Off",
|
|
19
|
+
};
|
|
20
|
+
/** The Notifications system app: active notifications, history, and settings. */
|
|
21
|
+
function NotificationsScreen() {
|
|
22
|
+
const [section, setSection] = (0, react_1.useState)("inbox");
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid py-3", style: { maxWidth: "48rem" }, children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center justify-content-between mb-3", children: [(0, jsx_runtime_1.jsx)("h4", { className: "m-0", children: "Notifications" }), (0, jsx_runtime_1.jsx)("div", { className: "btn-group btn-group-sm", role: "tablist", children: ["inbox", "history", "settings"].map((name) => ((0, jsx_runtime_1.jsx)("button", { type: "button", role: "tab", "aria-selected": section === name, className: `btn ${section === name ? "btn-primary" : "btn-outline-secondary"}`, onClick: () => setSection(name), children: name === "inbox" ? "Active" : name === "history" ? "History" : "Settings" }, name))) })] }), section === "settings" ? ((0, jsx_runtime_1.jsx)(NotificationSettings, {})) : ((0, jsx_runtime_1.jsx)(NotificationList, { section: section }, section))] }));
|
|
24
|
+
}
|
|
25
|
+
function NotificationList({ section }) {
|
|
26
|
+
const [cursor, setCursor] = (0, react_1.useState)({});
|
|
27
|
+
const { notifications, error } = (0, notifications_client_1.useNotifications)({
|
|
28
|
+
activeOnly: section === "inbox",
|
|
29
|
+
limit: 100,
|
|
30
|
+
...cursor,
|
|
31
|
+
});
|
|
32
|
+
const groupNames = (0, notification_bell_1.useGroupNames)();
|
|
33
|
+
if (error)
|
|
34
|
+
return (0, jsx_runtime_1.jsx)("div", { className: "alert alert-warning", children: error });
|
|
35
|
+
if (!notifications)
|
|
36
|
+
return (0, jsx_runtime_1.jsx)("div", { className: "text-body-secondary", children: "Loading\u2026" });
|
|
37
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "border rounded", children: [section === "inbox" && notifications.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex justify-content-end gap-3 px-2 py-1 border-bottom", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-link p-0", onClick: () => void (0, notifications_client_1.actOnNotifications)({ action: "seen", all: true }), children: "Mark all seen" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-link p-0", onClick: () => void (0, notifications_client_1.actOnNotifications)({ action: "dismiss", all: true }), children: "Clear all" })] })), notifications.length === 0 ? ((0, jsx_runtime_1.jsx)("div", { className: "p-3 text-body-secondary", children: section === "inbox" ? "You're all caught up." : "No notifications yet." })) : (notifications.map((notification) => ((0, jsx_runtime_1.jsx)(notification_item_1.NotificationItem, { notification: notification, groupName: groupNames.get(notification.groupId) }, notification.notificationId)))), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex justify-content-end gap-3 px-2 py-1", children: [cursor.before !== undefined && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-link", onClick: () => setCursor({}), children: "Newest notifications" })), notifications.length === 100 && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-link", onClick: () => {
|
|
38
|
+
const last = notifications[notifications.length - 1];
|
|
39
|
+
setCursor({ before: last.createdAt.getTime(), beforeId: last.notificationId });
|
|
40
|
+
}, children: "Older notifications" }))] })] }));
|
|
41
|
+
}
|
|
42
|
+
/** Sources the user has heard from, plus every group, so they can set a level for each. */
|
|
43
|
+
function useSources(history, rules) {
|
|
44
|
+
const groupNames = (0, notification_bell_1.useGroupNames)();
|
|
45
|
+
const [packageNames, setPackageNames] = (0, react_1.useState)(new Map());
|
|
46
|
+
const packageIds = (0, react_1.useMemo)(() => [
|
|
47
|
+
...new Set([
|
|
48
|
+
...(history ?? []).map((n) => n.sourcePackageId),
|
|
49
|
+
...(rules ?? []).map((rule) => rule.packageId),
|
|
50
|
+
].filter((id) => Boolean(id))),
|
|
51
|
+
], [history, rules]);
|
|
52
|
+
(0, react_1.useEffect)(() => {
|
|
53
|
+
let cancelled = false;
|
|
54
|
+
void (0, peers_sdk_1.getUserContext)().then(async (userContext) => {
|
|
55
|
+
const names = new Map();
|
|
56
|
+
// Only contexts this device holds: getDataContext would create one for a left group.
|
|
57
|
+
const groupIds = [userContext.userId, ...userContext.groupIds()];
|
|
58
|
+
for (const packageId of packageIds) {
|
|
59
|
+
for (const groupId of groupIds) {
|
|
60
|
+
const row = await (0, peers_sdk_1.Packages)(userContext.getDataContext(groupId))
|
|
61
|
+
.get(packageId)
|
|
62
|
+
.catch(() => undefined);
|
|
63
|
+
if (row?.name) {
|
|
64
|
+
names.set(packageId, row.name);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!cancelled)
|
|
70
|
+
setPackageNames(names);
|
|
71
|
+
});
|
|
72
|
+
return () => {
|
|
73
|
+
cancelled = true;
|
|
74
|
+
};
|
|
75
|
+
}, [packageIds]);
|
|
76
|
+
return (0, react_1.useMemo)(() => {
|
|
77
|
+
const sources = [];
|
|
78
|
+
for (const [groupId, name] of groupNames) {
|
|
79
|
+
sources.push({ label: `Group: ${name}`, match: { groupId } });
|
|
80
|
+
}
|
|
81
|
+
for (const packageId of packageIds) {
|
|
82
|
+
sources.push({
|
|
83
|
+
label: `App: ${packageNames.get(packageId) ?? packageId}`,
|
|
84
|
+
match: { packageId },
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const kinds = new Set();
|
|
88
|
+
for (const n of history ?? []) {
|
|
89
|
+
if (!n.sourcePackageId || !n.kind)
|
|
90
|
+
continue;
|
|
91
|
+
const key = `${n.sourcePackageId}:${n.kind}`;
|
|
92
|
+
if (kinds.has(key))
|
|
93
|
+
continue;
|
|
94
|
+
kinds.add(key);
|
|
95
|
+
sources.push({
|
|
96
|
+
label: `App: ${packageNames.get(n.sourcePackageId) ?? n.sourcePackageId} · ${n.kind}`,
|
|
97
|
+
match: { packageId: n.sourcePackageId, kind: n.kind },
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const people = new Map();
|
|
101
|
+
for (const n of history ?? []) {
|
|
102
|
+
if (n.fromUserId && !people.has(n.fromUserId))
|
|
103
|
+
people.set(n.fromUserId, n.fromName ?? n.fromUserId);
|
|
104
|
+
}
|
|
105
|
+
for (const [fromUserId, name] of people) {
|
|
106
|
+
sources.push({ label: `Person: ${name}`, match: { fromUserId } });
|
|
107
|
+
}
|
|
108
|
+
// A saved choice must remain editable after its source leaves the recent history page.
|
|
109
|
+
for (const rule of rules ?? []) {
|
|
110
|
+
if (sources.some((source) => sameMatch(rule, source.match)))
|
|
111
|
+
continue;
|
|
112
|
+
const { packageId, groupId, fromUserId, kind } = rule;
|
|
113
|
+
const label = [
|
|
114
|
+
groupId && `Group: ${groupNames.get(groupId) ?? groupId}`,
|
|
115
|
+
packageId && `App: ${packageNames.get(packageId) ?? packageId}`,
|
|
116
|
+
fromUserId && `Person: ${people.get(fromUserId) ?? fromUserId}`,
|
|
117
|
+
kind,
|
|
118
|
+
]
|
|
119
|
+
.filter(Boolean)
|
|
120
|
+
.join(" · ");
|
|
121
|
+
sources.push({
|
|
122
|
+
label: label || "All notifications",
|
|
123
|
+
match: { packageId, groupId, fromUserId, kind },
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return sources;
|
|
127
|
+
}, [groupNames, packageIds, packageNames, history, rules]);
|
|
128
|
+
}
|
|
129
|
+
function sameMatch(rule, match) {
|
|
130
|
+
return (rule.packageId === match.packageId &&
|
|
131
|
+
rule.groupId === match.groupId &&
|
|
132
|
+
rule.fromUserId === match.fromUserId &&
|
|
133
|
+
rule.kind === match.kind);
|
|
134
|
+
}
|
|
135
|
+
function NotificationSettings() {
|
|
136
|
+
const [settings] = (0, use_observable_1.useObservable)(peers_sdk_1.notificationSettingsVar);
|
|
137
|
+
const { notifications: history } = (0, notifications_client_1.useNotifications)({ limit: 300 });
|
|
138
|
+
const sources = useSources(history, settings?.rules);
|
|
139
|
+
const current = settings ?? {};
|
|
140
|
+
const rules = current.rules ?? [];
|
|
141
|
+
const now = Date.now();
|
|
142
|
+
const paused = (current.pausedUntil ?? 0) > now;
|
|
143
|
+
const save = (next) => (0, peers_sdk_1.notificationSettingsVar)(next);
|
|
144
|
+
const setRule = (match, change) => {
|
|
145
|
+
const existing = rules.find((rule) => sameMatch(rule, match));
|
|
146
|
+
const merged = { ...match, ...existing, ...change };
|
|
147
|
+
const others = rules.filter((rule) => rule !== existing);
|
|
148
|
+
const keep = merged.level !== undefined || merged.allowPriority !== undefined;
|
|
149
|
+
save({ ...current, rules: keep ? [...others, merged] : others });
|
|
150
|
+
};
|
|
151
|
+
const pauseFor = (ms) => save({ ...current, pausedUntil: ms === undefined ? undefined : Date.now() + ms });
|
|
152
|
+
const tomorrowMorning = () => {
|
|
153
|
+
const date = new Date();
|
|
154
|
+
// After midnight but before dawn, "tomorrow morning" is this morning.
|
|
155
|
+
if (date.getHours() >= 5)
|
|
156
|
+
date.setDate(date.getDate() + 1);
|
|
157
|
+
date.setHours(8, 0, 0, 0);
|
|
158
|
+
return date.getTime() - Date.now();
|
|
159
|
+
};
|
|
160
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-column gap-4", children: [(0, jsx_runtime_1.jsx)(ThisDeviceSettings, {}), (0, jsx_runtime_1.jsxs)("section", { children: [(0, jsx_runtime_1.jsx)("h6", { children: "Do not disturb" }), (0, jsx_runtime_1.jsx)("p", { className: "small text-body-secondary mb-2", children: "While paused, loud notifications arrive without sound. Priority notifications still come through." }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-wrap gap-2 align-items-center", children: [paused && ((0, jsx_runtime_1.jsxs)("span", { className: "small me-2", children: ["Paused until ", new Date(current.pausedUntil ?? 0).toLocaleString()] })), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-outline-secondary", onClick: () => pauseFor(60 * 60_000), children: "1 hour" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-outline-secondary", onClick: () => pauseFor(tomorrowMorning()), children: "Until tomorrow morning" }), paused && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-primary", onClick: () => pauseFor(undefined), children: "Resume" }))] })] }), (0, jsx_runtime_1.jsxs)("section", { children: [(0, jsx_runtime_1.jsx)("h6", { children: "Levels by source" }), (0, jsx_runtime_1.jsx)("p", { className: "small text-body-secondary mb-2", children: "Each app asks for a level; you decide what you get. More specific choices win, and a person can only use priority if you allow it here." }), (0, jsx_runtime_1.jsxs)("div", { className: "border rounded", children: [sources.length === 0 && ((0, jsx_runtime_1.jsx)("div", { className: "p-3 small text-body-secondary", children: "Sources appear here once you've had a notification from them." })), sources.map((source) => {
|
|
161
|
+
const rule = rules.find((r) => sameMatch(r, source.match));
|
|
162
|
+
const key = `${source.match.groupId ?? ""}:${source.match.packageId ?? ""}:${source.match.fromUserId ?? ""}:${source.match.kind ?? ""}`;
|
|
163
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-wrap align-items-center gap-2 px-2 py-2 border-bottom", children: [(0, jsx_runtime_1.jsx)("span", { className: "flex-grow-1 small", children: source.label }), (0, jsx_runtime_1.jsxs)("select", { className: "form-select form-select-sm", style: { width: "auto" }, "aria-label": `Level for ${source.label}`, value: rule?.level ?? "", onChange: (event) => setRule(source.match, {
|
|
164
|
+
level: (event.target.value || undefined),
|
|
165
|
+
}), children: [(0, jsx_runtime_1.jsx)("option", { value: "", children: "As the app asks" }), ["priority", "loud", "quiet", "background", "off"].map((level) => ((0, jsx_runtime_1.jsx)("option", { value: level, children: levelLabels[level] }, level)))] }), source.match.fromUserId && ((0, jsx_runtime_1.jsxs)("label", { className: "form-check-label small d-flex align-items-center gap-1", children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", className: "form-check-input m-0", checked: rule?.allowPriority === true, onChange: (event) => setRule(source.match, {
|
|
166
|
+
allowPriority: event.target.checked ? true : undefined,
|
|
167
|
+
}) }), "Allow priority"] }))] }, key));
|
|
168
|
+
})] })] })] }));
|
|
169
|
+
}
|
|
170
|
+
/** Per-device controls the host provides, such as the PWA's browser permission. */
|
|
171
|
+
function ThisDeviceSettings() {
|
|
172
|
+
const [controls] = (0, use_observable_1.useObservable)(host_controls_1.notificationHostControls);
|
|
173
|
+
const [busy, setBusy] = (0, react_1.useState)(false);
|
|
174
|
+
const [error, setError] = (0, react_1.useState)();
|
|
175
|
+
if (!controls)
|
|
176
|
+
return null;
|
|
177
|
+
const run = async (action) => {
|
|
178
|
+
if (!action)
|
|
179
|
+
return;
|
|
180
|
+
setBusy(true);
|
|
181
|
+
setError(undefined);
|
|
182
|
+
try {
|
|
183
|
+
await action();
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
187
|
+
}
|
|
188
|
+
finally {
|
|
189
|
+
setBusy(false);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
const stateLabel = {
|
|
193
|
+
unsupported: "Not available in this browser",
|
|
194
|
+
blocked: "Blocked by the browser",
|
|
195
|
+
off: "Off",
|
|
196
|
+
on: "On",
|
|
197
|
+
};
|
|
198
|
+
return ((0, jsx_runtime_1.jsxs)("section", { children: [(0, jsx_runtime_1.jsx)("h6", { children: "This device" }), (0, jsx_runtime_1.jsx)("p", { className: "small text-body-secondary mb-2", children: controls.description }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-wrap gap-2 align-items-center", children: [(0, jsx_runtime_1.jsxs)("span", { className: "small me-2", children: ["Notifications on this device: ", (0, jsx_runtime_1.jsx)("strong", { children: stateLabel[controls.state] })] }), controls.state === "off" && controls.enable && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-primary", disabled: busy, onClick: () => void run(controls.enable), children: "Turn on" })), controls.state === "on" && controls.disable && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-outline-secondary", disabled: busy, onClick: () => void run(controls.disable), children: "Turn off" }))] }), (error ?? controls.detail) && ((0, jsx_runtime_1.jsx)("p", { className: `small mb-0 mt-2 ${error ? "text-danger" : "text-body-secondary"}`, children: error ?? controls.detail }))] }));
|
|
199
|
+
}
|
|
200
|
+
(0, ui_loader_1.registerInternalPeersUI)({
|
|
201
|
+
component: NotificationsScreen,
|
|
202
|
+
routes: [
|
|
203
|
+
{
|
|
204
|
+
isMatch: (_props, context) => context.path === notifications_client_1.NOTIFICATIONS_PATH,
|
|
205
|
+
uiCategory: "screen",
|
|
206
|
+
priority: 0,
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PriorityAlert = PriorityAlert;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const global_overlays_1 = require("../root-layout/global-overlays");
|
|
7
|
+
const notifications_client_1 = require("./notifications-client");
|
|
8
|
+
/** Seconds between alarm chimes. */
|
|
9
|
+
const CHIME_REPEAT_MS = 4_000;
|
|
10
|
+
/** A falling-then-rising pair, distinct from the Timers chime. */
|
|
11
|
+
const CHIME_NOTES = [880, 659.25, 880];
|
|
12
|
+
function playChime(ctx) {
|
|
13
|
+
CHIME_NOTES.forEach((note, index) => {
|
|
14
|
+
const start = ctx.currentTime + index * 0.18;
|
|
15
|
+
const oscillator = ctx.createOscillator();
|
|
16
|
+
const gain = ctx.createGain();
|
|
17
|
+
oscillator.type = "triangle";
|
|
18
|
+
oscillator.frequency.value = note;
|
|
19
|
+
gain.gain.setValueAtTime(0, start);
|
|
20
|
+
gain.gain.linearRampToValueAtTime(0.35, start + 0.01);
|
|
21
|
+
gain.gain.exponentialRampToValueAtTime(0.0001, start + 0.5);
|
|
22
|
+
oscillator.connect(gain);
|
|
23
|
+
gain.connect(ctx.destination);
|
|
24
|
+
oscillator.start(start);
|
|
25
|
+
oscillator.stop(start + 0.5);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Banner and repeating chime for priority notifications ringing now. Shown above every layout
|
|
30
|
+
* until each one is acknowledged, snoozed, dismissed, or opened.
|
|
31
|
+
*/
|
|
32
|
+
function PriorityAlert() {
|
|
33
|
+
const summary = (0, notifications_client_1.useNotificationSummary)();
|
|
34
|
+
const ringingKey = summary.ringing.join(",");
|
|
35
|
+
const [ringing, setRinging] = (0, react_1.useState)([]);
|
|
36
|
+
(0, react_1.useEffect)(() => {
|
|
37
|
+
const ids = ringingKey ? ringingKey.split(",") : [];
|
|
38
|
+
if (!ids.length) {
|
|
39
|
+
setRinging([]);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
let cancelled = false;
|
|
43
|
+
void (0, notifications_client_1.listNotifications)({ notificationIds: ids, limit: ids.length })
|
|
44
|
+
.then((rows) => {
|
|
45
|
+
if (!cancelled)
|
|
46
|
+
setRinging(rows);
|
|
47
|
+
})
|
|
48
|
+
.catch(() => { });
|
|
49
|
+
return () => {
|
|
50
|
+
cancelled = true;
|
|
51
|
+
};
|
|
52
|
+
}, [ringingKey, summary.revision]);
|
|
53
|
+
(0, react_1.useEffect)(() => {
|
|
54
|
+
if (!ringingKey)
|
|
55
|
+
return;
|
|
56
|
+
const AudioCtx = window.AudioContext ||
|
|
57
|
+
window.webkitAudioContext;
|
|
58
|
+
if (!AudioCtx)
|
|
59
|
+
return;
|
|
60
|
+
const ctx = new AudioCtx();
|
|
61
|
+
const chime = () => {
|
|
62
|
+
if (ctx.state === "running")
|
|
63
|
+
playChime(ctx);
|
|
64
|
+
else if (ctx.state === "suspended")
|
|
65
|
+
void ctx.resume().catch(() => { });
|
|
66
|
+
};
|
|
67
|
+
chime();
|
|
68
|
+
const timer = setInterval(chime, CHIME_REPEAT_MS);
|
|
69
|
+
return () => {
|
|
70
|
+
clearInterval(timer);
|
|
71
|
+
void ctx.close().catch(() => { });
|
|
72
|
+
};
|
|
73
|
+
}, [ringingKey]);
|
|
74
|
+
if (!summary.ringing.length)
|
|
75
|
+
return null;
|
|
76
|
+
// The summary owns the alarm session, even while details are loading or a read fails.
|
|
77
|
+
// Never leave controls aimed at a handled alarm when a different one starts ringing.
|
|
78
|
+
const ids = summary.ringing;
|
|
79
|
+
const first = ringing.find((n) => ids.includes(n.notificationId));
|
|
80
|
+
return ((0, jsx_runtime_1.jsxs)("div", { role: "alertdialog", "aria-live": "assertive", "aria-label": "Priority notification", className: "position-fixed start-50 translate-middle-x bg-danger text-white rounded shadow-lg p-3 d-flex flex-column gap-2", style: { top: "1rem", zIndex: 2000, width: "min(28rem, calc(100vw - 2rem))" }, "data-testid": "priority-alert", children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-start gap-2", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-alarm-fill fs-4", "aria-hidden": "true" }), (0, jsx_runtime_1.jsxs)("div", { style: { minWidth: 0 }, children: [(0, jsx_runtime_1.jsx)("div", { className: "fw-semibold", children: first?.title ?? "Priority notification" }), first?.body && (0, jsx_runtime_1.jsx)("div", { className: "small", children: first.body }), ids.length > 1 && (0, jsx_runtime_1.jsxs)("div", { className: "small opacity-75", children: ["and ", ids.length - 1, " more"] })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-wrap gap-2 justify-content-end", children: [first?.link && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-light", onClick: () => void (0, notifications_client_1.openNotification)(first), children: "Open" })), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-outline-light", onClick: () => void (0, notifications_client_1.actOnNotifications)({ action: "snooze", notificationIds: ids, snoozeMinutes: 5 }), children: "Snooze 5 min" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-light fw-semibold", onClick: () => void (0, notifications_client_1.actOnNotifications)({ action: "acknowledge", notificationIds: ids }), children: "Acknowledge" })] })] }));
|
|
81
|
+
}
|
|
82
|
+
(0, global_overlays_1.registerGlobalOverlay)("system-notifications-priority", PriorityAlert);
|
|
@@ -17,6 +17,7 @@ const command_palette_1 = require("../../command-palette/command-palette");
|
|
|
17
17
|
const group_switcher_1 = require("../../components/group-switcher");
|
|
18
18
|
const globals_1 = require("../../globals");
|
|
19
19
|
const hooks_1 = require("../../hooks");
|
|
20
|
+
const notification_bell_1 = require("../../notifications/notification-bell");
|
|
20
21
|
const color_mode_dropdown_1 = require("../../screens/settings/color-mode-dropdown");
|
|
21
22
|
const tabs_layout_1 = require("../../tabs-layout/tabs-layout");
|
|
22
23
|
const tabs_state_1 = require("../../tabs-layout/tabs-state");
|
|
@@ -38,7 +39,7 @@ function FullScreenLayout() {
|
|
|
38
39
|
const isLauncher = activeTab.packageId === "launcher" || activeTab.tabId === "launcher";
|
|
39
40
|
const isLight = mode === "light";
|
|
40
41
|
const title = isLauncher ? "Apps" : activeTab.title;
|
|
41
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-column", style: { height: "calc(100vh - 25px)", overflow: "hidden" }, children: [(0, jsx_runtime_1.jsxs)("div", { className: `border-bottom peers-tab-strip d-flex align-items-center px-1 ${isLight ? "" : "bg-dark"}`, style: { height: "36px", borderBottomColor: isLight ? "var(--peers-tab-edge)" : "#495057" }, children: [(0, jsx_runtime_1.jsx)(group_switcher_1.GroupSwitcher, { colorMode: mode, isMobile: isMobile }), (0, jsx_runtime_1.jsx)(HeaderButton, { isLight: isLight, active: isLauncher, icon: "bi-grid-3x3-gap", label: "Apps", onClick: () => (0, tabs_state_1.activeTabId)("launcher") }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center flex-grow-1 overflow-hidden px-2", children: [!isLauncher && activeTab.iconClassName && ((0, jsx_runtime_1.jsx)("i", { className: `${activeTab.iconClassName} me-2` })), (0, jsx_runtime_1.jsx)("span", { className: "text-truncate fw-medium", style: { fontSize: "13px" }, children: title })] }), (0, jsx_runtime_1.jsx)(HeaderButton, { isLight: isLight, icon: "bi-search", label: `Search and navigate (${paletteHint})`, onClick: command_palette_1.openCommandPalette, children: (0, jsx_runtime_1.jsx)("span", { className: "d-none d-md-inline ms-1", style: { fontSize: "11px" }, children: paletteHint }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex-grow-1 overflow-hidden", children: (0, jsx_runtime_1.jsx)(tabs_layout_1.TabErrorBoundary, { tabTitle: activeTab.title, tabId: activeTab.tabId, children: (0, jsx_runtime_1.jsx)(tabs_layout_1.TabContent, { tab: activeTab, isMobile: isMobile, isActive: true }) }, activeTab.tabId) })] }));
|
|
42
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-column", style: { height: "calc(100vh - 25px)", overflow: "hidden" }, children: [(0, jsx_runtime_1.jsxs)("div", { className: `border-bottom peers-tab-strip d-flex align-items-center px-1 ${isLight ? "" : "bg-dark"}`, style: { height: "36px", borderBottomColor: isLight ? "var(--peers-tab-edge)" : "#495057" }, children: [(0, jsx_runtime_1.jsx)(group_switcher_1.GroupSwitcher, { colorMode: mode, isMobile: isMobile }), (0, jsx_runtime_1.jsx)(HeaderButton, { isLight: isLight, active: isLauncher, icon: "bi-grid-3x3-gap", label: "Apps", onClick: () => (0, tabs_state_1.activeTabId)("launcher") }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center flex-grow-1 overflow-hidden px-2", children: [!isLauncher && activeTab.iconClassName && ((0, jsx_runtime_1.jsx)("i", { className: `${activeTab.iconClassName} me-2` })), (0, jsx_runtime_1.jsx)("span", { className: "text-truncate fw-medium", style: { fontSize: "13px" }, children: title })] }), (0, jsx_runtime_1.jsx)(notification_bell_1.NotificationBell, { compact: true }), (0, jsx_runtime_1.jsx)(HeaderButton, { isLight: isLight, icon: "bi-search", label: `Search and navigate (${paletteHint})`, onClick: command_palette_1.openCommandPalette, children: (0, jsx_runtime_1.jsx)("span", { className: "d-none d-md-inline ms-1", style: { fontSize: "11px" }, children: paletteHint }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex-grow-1 overflow-hidden", children: (0, jsx_runtime_1.jsx)(tabs_layout_1.TabErrorBoundary, { tabTitle: activeTab.title, tabId: activeTab.tabId, children: (0, jsx_runtime_1.jsx)(tabs_layout_1.TabContent, { tab: activeTab, isMobile: isMobile, isActive: true }) }, activeTab.tabId) })] }));
|
|
42
43
|
}
|
|
43
44
|
/** A small, transparent header button matching the tabs layout's toolbar styling. */
|
|
44
45
|
function HeaderButton({ isLight, icon, label, onClick, active, children }) {
|
|
@@ -20,6 +20,7 @@ const react_1 = require("react");
|
|
|
20
20
|
const command_palette_ui_1 = require("../command-palette/command-palette-ui");
|
|
21
21
|
const globals_1 = require("../globals");
|
|
22
22
|
const hooks_1 = require("../hooks");
|
|
23
|
+
const notifications_client_1 = require("../notifications/notifications-client");
|
|
23
24
|
const identity_ipc_1 = require("../screens/device-pairing/identity-ipc");
|
|
24
25
|
const identity_routes_1 = require("../screens/identity/identity-routes");
|
|
25
26
|
const invite_capture_1 = require("../screens/invites/invite-capture");
|
|
@@ -95,6 +96,7 @@ function RootLayoutBootstrap(props) {
|
|
|
95
96
|
peers_sdk_1.hasShownWelcomeModal.loadingPromise,
|
|
96
97
|
]);
|
|
97
98
|
(0, globals_1.initializeHashNavigation)();
|
|
99
|
+
await (0, notifications_client_1.resumeNotificationNavigation)();
|
|
98
100
|
if ((0, invite_capture_1.peekPendingInvite)()) {
|
|
99
101
|
(0, globals_1.mainContentPath)(identity_routes_1.IDENTITY_ACCEPT_PATH);
|
|
100
102
|
}
|
|
@@ -6,6 +6,7 @@ export { dataExplorerApp } from "./data-explorer.app";
|
|
|
6
6
|
export { identityApp } from "./identity.app";
|
|
7
7
|
export { mobileSettingsApp } from "./mobile-settings.app";
|
|
8
8
|
export { networkViewerApp } from "./network-viewer.app";
|
|
9
|
+
export { notificationsApp } from "./notifications.app";
|
|
9
10
|
export { packagesApp } from "./packages.app";
|
|
10
11
|
export { searchApp } from "./search.app";
|
|
11
12
|
export { settingsApp } from "./settings.app";
|
|
@@ -14,5 +15,7 @@ export { toolsApp } from "./tools.app";
|
|
|
14
15
|
export { typesApp } from "./types.app";
|
|
15
16
|
export { variablesApp } from "./variables.app";
|
|
16
17
|
export { workflowsApp } from "./workflows.app";
|
|
18
|
+
/** Every built-in app, in launcher order. Mobile Settings appears only in React Native. */
|
|
17
19
|
export declare const systemApps: IAppNav[];
|
|
20
|
+
/** Virtual package that holds {@link systemApps}, so tabs and search treat them like packages. */
|
|
18
21
|
export declare const systemPackage: IPackageWithNavs;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.systemPackage = exports.systemApps = exports.workflowsApp = exports.variablesApp = exports.typesApp = exports.toolsApp = exports.threadsApp = exports.settingsApp = exports.searchApp = exports.packagesApp = exports.networkViewerApp = exports.mobileSettingsApp = exports.identityApp = exports.dataExplorerApp = exports.consoleLogsApp = exports.assistantsApp = void 0;
|
|
3
|
+
exports.systemPackage = exports.systemApps = exports.workflowsApp = exports.variablesApp = exports.typesApp = exports.toolsApp = exports.threadsApp = exports.settingsApp = exports.searchApp = exports.packagesApp = exports.notificationsApp = exports.networkViewerApp = exports.mobileSettingsApp = exports.identityApp = exports.dataExplorerApp = exports.consoleLogsApp = exports.assistantsApp = void 0;
|
|
4
4
|
var assistants_app_1 = require("./assistants.app");
|
|
5
5
|
Object.defineProperty(exports, "assistantsApp", { enumerable: true, get: function () { return assistants_app_1.assistantsApp; } });
|
|
6
6
|
var console_logs_app_1 = require("./console-logs.app");
|
|
@@ -13,6 +13,8 @@ var mobile_settings_app_1 = require("./mobile-settings.app");
|
|
|
13
13
|
Object.defineProperty(exports, "mobileSettingsApp", { enumerable: true, get: function () { return mobile_settings_app_1.mobileSettingsApp; } });
|
|
14
14
|
var network_viewer_app_1 = require("./network-viewer.app");
|
|
15
15
|
Object.defineProperty(exports, "networkViewerApp", { enumerable: true, get: function () { return network_viewer_app_1.networkViewerApp; } });
|
|
16
|
+
var notifications_app_1 = require("./notifications.app");
|
|
17
|
+
Object.defineProperty(exports, "notificationsApp", { enumerable: true, get: function () { return notifications_app_1.notificationsApp; } });
|
|
16
18
|
var packages_app_1 = require("./packages.app");
|
|
17
19
|
Object.defineProperty(exports, "packagesApp", { enumerable: true, get: function () { return packages_app_1.packagesApp; } });
|
|
18
20
|
// Import all system apps
|
|
@@ -36,6 +38,7 @@ const data_explorer_app_2 = require("./data-explorer.app");
|
|
|
36
38
|
const identity_app_2 = require("./identity.app");
|
|
37
39
|
const mobile_settings_app_2 = require("./mobile-settings.app");
|
|
38
40
|
const network_viewer_app_2 = require("./network-viewer.app");
|
|
41
|
+
const notifications_app_2 = require("./notifications.app");
|
|
39
42
|
const packages_app_2 = require("./packages.app");
|
|
40
43
|
// Import individual apps
|
|
41
44
|
const search_app_2 = require("./search.app");
|
|
@@ -49,7 +52,7 @@ const workflows_app_2 = require("./workflows.app");
|
|
|
49
52
|
function isReactNative() {
|
|
50
53
|
return typeof window.__NATIVE_THEME !== "undefined";
|
|
51
54
|
}
|
|
52
|
-
|
|
55
|
+
/** Every built-in app, in launcher order. Mobile Settings appears only in React Native. */
|
|
53
56
|
exports.systemApps = [
|
|
54
57
|
// Core Navigation & Search
|
|
55
58
|
search_app_2.searchApp,
|
|
@@ -67,11 +70,12 @@ exports.systemApps = [
|
|
|
67
70
|
packages_app_2.packagesApp,
|
|
68
71
|
identity_app_2.identityApp,
|
|
69
72
|
// User & Settings Apps
|
|
73
|
+
notifications_app_2.notificationsApp,
|
|
70
74
|
settings_app_2.settingsApp,
|
|
71
75
|
// Mobile Settings (only in React Native)
|
|
72
76
|
...(isReactNative() ? [mobile_settings_app_2.mobileSettingsApp] : []),
|
|
73
77
|
];
|
|
74
|
-
|
|
78
|
+
/** Virtual package that holds {@link systemApps}, so tabs and search treat them like packages. */
|
|
75
79
|
exports.systemPackage = {
|
|
76
80
|
packageId: "system-apps",
|
|
77
81
|
name: "System Apps",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.notificationsApp = void 0;
|
|
4
|
+
/** The built-in inbox, history, and notification settings app. */
|
|
5
|
+
exports.notificationsApp = {
|
|
6
|
+
name: "Notifications",
|
|
7
|
+
iconClassName: "bi-bell-fill",
|
|
8
|
+
navigationPath: "notifications",
|
|
9
|
+
};
|
|
@@ -16,6 +16,7 @@ const react_1 = require("react");
|
|
|
16
16
|
const app_update_controls_1 = require("../app-updates/app-update-controls");
|
|
17
17
|
const app_updates_consumer_1 = require("../app-updates/app-updates-consumer");
|
|
18
18
|
const use_app_update_status_1 = require("../app-updates/use-app-update-status");
|
|
19
|
+
const notification_bell_1 = require("../notifications/notification-bell");
|
|
19
20
|
const identity_routes_1 = require("../screens/identity/identity-routes");
|
|
20
21
|
const network_viewer_ipc_1 = require("../screens/network-viewer/network-viewer-ipc");
|
|
21
22
|
const network_viewer_section_1 = require("../screens/network-viewer/network-viewer-section");
|
|
@@ -395,5 +396,5 @@ function NetworkStatusIndicator({ compact = false }) {
|
|
|
395
396
|
}
|
|
396
397
|
/** Fixed tabs-strip area for built-in shell indicators. */
|
|
397
398
|
function TabsStripIndicators({ compact = false }) {
|
|
398
|
-
return ((0, jsx_runtime_1.
|
|
399
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center flex-shrink-0", role: "group", "aria-label": "Application status", children: [(0, jsx_runtime_1.jsx)(notification_bell_1.NotificationBell, { compact: compact }), (0, jsx_runtime_1.jsx)(NetworkStatusIndicator, { compact: compact })] }));
|
|
399
400
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peers-app/peers-ui",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/peers-app/peers-ui.git"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"lint:fix": "biome check --write ."
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@peers-app/peers-sdk": "^0.32.
|
|
39
|
+
"@peers-app/peers-sdk": "^0.32.3",
|
|
40
40
|
"bootstrap": "^5.3.3",
|
|
41
41
|
"react": "^18.0.0",
|
|
42
42
|
"react-dom": "^18.0.0"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@babel/preset-react": "^7.24.1",
|
|
48
48
|
"@babel/preset-typescript": "^7.27.1",
|
|
49
49
|
"@biomejs/biome": "2.3.11",
|
|
50
|
-
"@peers-app/peers-sdk": "0.32.
|
|
50
|
+
"@peers-app/peers-sdk": "0.32.3",
|
|
51
51
|
"@testing-library/dom": "^10.4.0",
|
|
52
52
|
"@testing-library/jest-dom": "^6.6.3",
|
|
53
53
|
"@testing-library/react": "^16.3.0",
|