Optimize Notifications Rendering

This commit is contained in:
Shpuld Shpludson 2020-01-14 13:28:57 +00:00
parent dd740043c6
commit 86380f0429
5 changed files with 30 additions and 9 deletions

View file

@ -26,7 +26,7 @@ const sortById = (a, b) => {
}
}
export const visibleNotificationsFromStore = (store, types) => {
export const filteredNotificationsFromStore = (store, types) => {
// map is just to clone the array since sort mutates it and it causes some issues
let sortedNotifications = notificationsFromStore(store).map(_ => _).sort(sortById)
sortedNotifications = sortBy(sortedNotifications, 'seen')
@ -36,4 +36,4 @@ export const visibleNotificationsFromStore = (store, types) => {
}
export const unseenNotificationsFromStore = store =>
filter(visibleNotificationsFromStore(store), ({ seen }) => !seen)
filter(filteredNotificationsFromStore(store), ({ seen }) => !seen)