2016-11-20 13:39:18 -05:00
|
|
|
import { connect } from 'react-redux';
|
2023-05-23 11:15:17 -04:00
|
|
|
|
2017-10-05 19:07:59 -04:00
|
|
|
import { mentionCompose } from '../../../actions/compose';
|
2019-01-27 11:54:54 -05:00
|
|
|
import {
|
2024-07-22 11:45:07 -04:00
|
|
|
toggleFavourite,
|
|
|
|
toggleReblog,
|
2019-01-27 11:54:54 -05:00
|
|
|
} from '../../../actions/interactions';
|
|
|
|
import {
|
|
|
|
hideStatus,
|
|
|
|
revealStatus,
|
|
|
|
} from '../../../actions/statuses';
|
2023-05-23 11:15:17 -04:00
|
|
|
import { makeGetNotification, makeGetStatus, makeGetReport } from '../../../selectors';
|
|
|
|
import Notification from '../components/notification';
|
2016-11-20 13:39:18 -05:00
|
|
|
|
|
|
|
const makeMapStateToProps = () => {
|
|
|
|
const getNotification = makeGetNotification();
|
2019-01-27 11:54:54 -05:00
|
|
|
const getStatus = makeGetStatus();
|
2022-06-27 03:30:15 -04:00
|
|
|
const getReport = makeGetReport();
|
2016-11-20 13:39:18 -05:00
|
|
|
|
2019-01-27 11:54:54 -05:00
|
|
|
const mapStateToProps = (state, props) => {
|
|
|
|
const notification = getNotification(state, props.notification, props.accountId);
|
|
|
|
return {
|
|
|
|
notification: notification,
|
2023-01-23 07:21:50 -05:00
|
|
|
status: notification.get('status') ? getStatus(state, { id: notification.get('status'), contextType: 'notifications' }) : null,
|
2022-06-27 03:30:15 -04:00
|
|
|
report: notification.get('report') ? getReport(state, notification.get('report'), notification.getIn(['report', 'target_account', 'id'])) : null,
|
2019-01-27 11:54:54 -05:00
|
|
|
};
|
|
|
|
};
|
2016-11-20 13:39:18 -05:00
|
|
|
|
|
|
|
return mapStateToProps;
|
|
|
|
};
|
|
|
|
|
2017-10-05 19:07:59 -04:00
|
|
|
const mapDispatchToProps = dispatch => ({
|
2024-07-19 11:26:44 -04:00
|
|
|
onMention: (account) => {
|
|
|
|
dispatch(mentionCompose(account));
|
2017-10-05 19:07:59 -04:00
|
|
|
},
|
2019-01-27 11:54:54 -05:00
|
|
|
|
|
|
|
onReblog (status, e) {
|
2024-07-22 11:45:07 -04:00
|
|
|
dispatch(toggleReblog(status.get('id'), e.shiftKey));
|
2019-01-27 11:54:54 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
onFavourite (status) {
|
2024-07-22 11:45:07 -04:00
|
|
|
dispatch(toggleFavourite(status.get('id')));
|
2019-01-27 11:54:54 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
onToggleHidden (status) {
|
|
|
|
if (status.get('hidden')) {
|
|
|
|
dispatch(revealStatus(status.get('id')));
|
|
|
|
} else {
|
|
|
|
dispatch(hideStatus(status.get('id')));
|
|
|
|
}
|
|
|
|
},
|
2017-10-05 19:07:59 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(makeMapStateToProps, mapDispatchToProps)(Notification);
|