| 244 | } |
| 245 | |
| 246 | const appendToIndex = (notification: Notification) => { |
| 247 | if (notification.session) { |
| 248 | setIndex("session", "all", notification.session, (all = []) => [...all, notification]) |
| 249 | if (!notification.viewed) { |
| 250 | setIndex("session", "unseen", notification.session, (unseen = []) => [...unseen, notification]) |
| 251 | setIndex("session", "unseenCount", notification.session, (count = 0) => count + 1) |
| 252 | if (notification.type === "error") setIndex("session", "unseenHasError", notification.session, true) |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | if (notification.directory) { |
| 257 | setIndex("project", "all", notification.directory, (all = []) => [...all, notification]) |
| 258 | if (!notification.viewed) { |
| 259 | setIndex("project", "unseen", notification.directory, (unseen = []) => [...unseen, notification]) |
| 260 | setIndex("project", "unseenCount", notification.directory, (count = 0) => count + 1) |
| 261 | if (notification.type === "error") setIndex("project", "unseenHasError", notification.directory, true) |
| 262 | } |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | const removeFromIndex = (notification: Notification) => { |
| 267 | if (notification.session) { |