change getNotifications to use filter
This commit is contained in:
parent
7b00332167
commit
b8705a7bf2
|
@ -23,8 +23,8 @@ export default class FilterBar extends React.PureComponent {
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={selectedFilter === 'mentions' ? 'active' : ''}
|
className={selectedFilter === 'mention' ? 'active' : ''}
|
||||||
onClick={() => selectFilter('mentions')}
|
onClick={() => selectFilter('mention')}
|
||||||
>
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='notifications.filter.mentions'
|
id='notifications.filter.mentions'
|
||||||
|
@ -32,8 +32,8 @@ export default class FilterBar extends React.PureComponent {
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={selectedFilter === 'favourites' ? 'active' : ''}
|
className={selectedFilter === 'favourite' ? 'active' : ''}
|
||||||
onClick={() => selectFilter('favourites')}
|
onClick={() => selectFilter('favourite')}
|
||||||
>
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='notifications.filter.favourites'
|
id='notifications.filter.favourites'
|
||||||
|
@ -41,8 +41,8 @@ export default class FilterBar extends React.PureComponent {
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={selectedFilter === 'boosts' ? 'active' : ''}
|
className={selectedFilter === 'reblog' ? 'active' : ''}
|
||||||
onClick={() => selectFilter('boosts')}
|
onClick={() => selectFilter('reblog')}
|
||||||
>
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='notifications.filter.boosts'
|
id='notifications.filter.boosts'
|
||||||
|
@ -50,8 +50,8 @@ export default class FilterBar extends React.PureComponent {
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={selectedFilter === 'follows' ? 'active' : ''}
|
className={selectedFilter === 'follow' ? 'active' : ''}
|
||||||
onClick={() => selectFilter('follows')}
|
onClick={() => selectFilter('follow')}
|
||||||
>
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='notifications.filter.follows'
|
id='notifications.filter.follows'
|
||||||
|
|
|
@ -20,11 +20,16 @@ const messages = defineMessages({
|
||||||
title: { id: 'column.notifications', defaultMessage: 'Notifications' },
|
title: { id: 'column.notifications', defaultMessage: 'Notifications' },
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Modify this to filter notifications
|
|
||||||
const getNotifications = createSelector([
|
const getNotifications = createSelector([
|
||||||
|
state => state.getIn(['settings', 'notifications', 'filter']),
|
||||||
state => ImmutableList(state.getIn(['settings', 'notifications', 'shows']).filter(item => !item).keys()),
|
state => ImmutableList(state.getIn(['settings', 'notifications', 'shows']).filter(item => !item).keys()),
|
||||||
state => state.getIn(['notifications', 'items']),
|
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 => ({
|
const mapStateToProps = state => ({
|
||||||
notifications: getNotifications(state),
|
notifications: getNotifications(state),
|
||||||
|
|
Loading…
Reference in New Issue