Files
Prowlarr/frontend/src/Settings/Notifications/Notifications/NotificationsConnector.js
T
Mark McDowall 76f30e7682 New: Use natural sorting for lists of items in the UI
(cherry picked from commit 1a1c8e6c08a6db5fcd2b5d17e65fa1f943d2e746)
2024-07-18 21:35:06 +03:00

64 lines
1.5 KiB
JavaScript

import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { deleteNotification, fetchNotifications } from 'Store/Actions/settingsActions';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import createTagsSelector from 'Store/Selectors/createTagsSelector';
import sortByProp from 'Utilities/Array/sortByProp';
import Notifications from './Notifications';
function createMapStateToProps() {
return createSelector(
createSortedSectionSelector('settings.notifications', sortByProp('name')),
createTagsSelector(),
(notifications, tagList) => {
return {
...notifications,
tagList
};
}
);
}
const mapDispatchToProps = {
fetchNotifications,
deleteNotification
};
class NotificationsConnector extends Component {
//
// Lifecycle
componentDidMount() {
this.props.fetchNotifications();
}
//
// Listeners
onConfirmDeleteNotification = (id) => {
this.props.deleteNotification({ id });
};
//
// Render
render() {
return (
<Notifications
{...this.props}
onConfirmDeleteNotification={this.onConfirmDeleteNotification}
/>
);
}
}
NotificationsConnector.propTypes = {
fetchNotifications: PropTypes.func.isRequired,
deleteNotification: PropTypes.func.isRequired
};
export default connect(createMapStateToProps, mapDispatchToProps)(NotificationsConnector);