change getNotifications to use filter

pull/9399/head
alxd 2018-11-30 13:00:29 +01:00
parent 7b00332167
commit b8705a7bf2
2 changed files with 15 additions and 10 deletions

View File

@ -23,8 +23,8 @@ export default class FilterBar extends React.PureComponent {
/>
</button>
<button
className={selectedFilter === 'mentions' ? 'active' : ''}
onClick={() => selectFilter('mentions')}
className={selectedFilter === 'mention' ? 'active' : ''}
onClick={() => selectFilter('mention')}
>
<FormattedMessage
id='notifications.filter.mentions'
@ -32,8 +32,8 @@ export default class FilterBar extends React.PureComponent {
/>
</button>
<button
className={selectedFilter === 'favourites' ? 'active' : ''}
onClick={() => selectFilter('favourites')}
className={selectedFilter === 'favourite' ? 'active' : ''}
onClick={() => selectFilter('favourite')}
>
<FormattedMessage
id='notifications.filter.favourites'
@ -41,8 +41,8 @@ export default class FilterBar extends React.PureComponent {
/>
</button>
<button
className={selectedFilter === 'boosts' ? 'active' : ''}
onClick={() => selectFilter('boosts')}
className={selectedFilter === 'reblog' ? 'active' : ''}
onClick={() => selectFilter('reblog')}
>
<FormattedMessage
id='notifications.filter.boosts'
@ -50,8 +50,8 @@ export default class FilterBar extends React.PureComponent {
/>
</button>
<button
className={selectedFilter === 'follows' ? 'active' : ''}
onClick={() => selectFilter('follows')}
className={selectedFilter === 'follow' ? 'active' : ''}
onClick={() => selectFilter('follow')}
>
<FormattedMessage
id='notifications.filter.follows'

View File

@ -20,11 +20,16 @@ const messages = defineMessages({
title: { id: 'column.notifications', defaultMessage: 'Notifications' },
});
// TODO: Modify this to filter notifications
const getNotifications = createSelector([
state => state.getIn(['settings', 'notifications', 'filter']),
state => ImmutableList(state.getIn(['settings', 'notifications', 'shows']).filter(item => !item).keys()),
state => state.getIn(['notifications', 'items']),
], (excludedTypes, notifications) => notifications.filterNot(item => item !== null && excludedTypes.includes(item.get('type'))));
], (allowedType, excludedTypes, notifications) => {
if (allowedType === 'all') {
return notifications.filterNot(item => item !== null && excludedTypes.includes(item.get('type')));
}
return notifications.filter(item => item !== null && allowedType === item.get('type'))
});
const mapStateToProps = state => ({
notifications: getNotifications(state),