MCPcopy Create free account
hub / github.com/anomalyco/opencode / buildNotificationIndex

Function buildNotificationIndex

packages/app/src/context/notification.tsx:82–110  ·  view source on GitHub ↗
(list: Notification[])

Source from the content-addressed store, hash-verified

80}
81
82function buildNotificationIndex(list: Notification[]) {
83 const index = createNotificationIndex()
84
85 list.forEach((notification) => {
86 if (notification.session) {
87 const all = index.session.all[notification.session] ?? []
88 index.session.all[notification.session] = [...all, notification]
89 if (!notification.viewed) {
90 const unseen = index.session.unseen[notification.session] ?? []
91 index.session.unseen[notification.session] = [...unseen, notification]
92 index.session.unseenCount[notification.session] = unseen.length + 1
93 if (notification.type === "error") index.session.unseenHasError[notification.session] = true
94 }
95 }
96
97 if (notification.directory) {
98 const all = index.project.all[notification.directory] ?? []
99 index.project.all[notification.directory] = [...all, notification]
100 if (!notification.viewed) {
101 const unseen = index.project.unseen[notification.directory] ?? []
102 index.project.unseen[notification.directory] = [...unseen, notification]
103 index.project.unseenCount[notification.directory] = unseen.length + 1
104 if (notification.type === "error") index.project.unseenHasError[notification.directory] = true
105 }
106 }
107 })
108
109 return index
110}
111
112export const { use: useNotification, provider: NotificationProvider } = createSimpleContext({
113 name: "Notification",

Callers 1

Calls 1

createNotificationIndexFunction · 0.85

Tested by

no test coverage detected