Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

Commit

Permalink
simplify getNotifications once frontend filtering is not needed for F…
Browse files Browse the repository at this point in the history
…ilterBar
  • Loading branch information
pawelngei committed Dec 12, 2018
1 parent 0a9de4a commit 9f4be78
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions app/javascript/mastodon/features/notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,12 @@ const messages = defineMessages({
});

const getNotifications = createSelector([
// TODO: Remove the first two arguments and simplify
state => state.getIn(['settings', 'notifications', 'quickFilter', 'show']),
state => state.getIn(['settings', 'notifications', 'quickFilter', 'active']),
state => ImmutableList(state.getIn(['settings', 'notifications', 'shows']).filter(item => !item).keys()),
state => state.getIn(['notifications', 'items']),
], (showFilterBar, allowedType, excludedTypes, notifications) => {
if (!showFilterBar || allowedType === 'all') {
// used if user changed the notification settings after loading the notifications from the server
// otherwise a list of notifications will come pre-filtered from the backend
return notifications.filterNot(item => item !== null && excludedTypes.includes(item.get('type')));
}
return notifications.filter(item => item !== null && allowedType === item.get('type'));
], (excludedTypes, notifications) => {
// used if user changed the notification settings after loading the notifications from the server
// otherwise a list of notifications will come pre-filtered from the backend
return notifications.filterNot(item => item !== null && excludedTypes.includes(item.get('type')));
});

const mapStateToProps = state => ({
Expand Down

0 comments on commit 9f4be78

Please sign in to comment.