MCPcopy Create free account
hub / github.com/codeaashu/claude-code / useNotifications

Function useNotifications

web/hooks/useNotifications.ts:15–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13}
14
15export function useNotifications() {
16 const notifications = useNotificationStore((s) => s.notifications);
17 const browserNotificationsEnabled = useNotificationStore(
18 (s) => s.browserNotificationsEnabled
19 );
20 const addNotification = useNotificationStore((s) => s.addNotification);
21 const markRead = useNotificationStore((s) => s.markRead);
22 const markAllRead = useNotificationStore((s) => s.markAllRead);
23 const clearHistory = useNotificationStore((s) => s.clearHistory);
24
25 const notify = useCallback(
26 async (options: NotifyOptions) => {
27 addNotification({
28 title: options.title,
29 description: options.description,
30 category: options.category,
31 link: options.link,
32 });
33
34 if (options.browserNotification && browserNotificationsEnabled) {
35 await browserNotifications.send({
36 title: options.title,
37 body: options.description,
38 });
39 }
40 },
41 [addNotification, browserNotificationsEnabled]
42 );
43
44 const unreadCount = notifications.filter((n) => !n.read).length;
45
46 return {
47 notifications,
48 unreadCount,
49 notify,
50 markRead,
51 markAllRead,
52 clearHistory,
53 };
54}

Callers 1

NotificationCenterFunction · 0.90

Calls 1

sendMethod · 0.65

Tested by

no test coverage detected