2016-11-21 03:39:18 +09:00
|
|
|
import { connect } from 'react-redux';
|
2023-05-24 00:15:17 +09:00
|
|
|
|
2017-10-06 08:07:59 +09:00
|
|
|
import { mentionCompose } from '../../../actions/compose';
|
2019-01-28 01:54:54 +09:00
|
|
|
import {
|
|
|
|
reblog,
|
|
|
|
favourite,
|
|
|
|
unreblog,
|
|
|
|
unfavourite,
|
|
|
|
} from '../../../actions/interactions';
|
2024-03-29 00:33:15 +09:00
|
|
|
import { openModal } from '../../../actions/modal';
|
2019-01-28 01:54:54 +09:00
|
|
|
import {
|
|
|
|
hideStatus,
|
|
|
|
revealStatus,
|
|
|
|
} from '../../../actions/statuses';
|
|
|
|
import { boostModal } from '../../../initial_state';
|
2023-05-24 00:15:17 +09:00
|
|
|
import { makeGetNotification, makeGetStatus, makeGetReport } from '../../../selectors';
|
|
|
|
import Notification from '../components/notification';
|
2016-11-21 03:39:18 +09:00
|
|
|
|
|
|
|
const makeMapStateToProps = () => {
|
|
|
|
const getNotification = makeGetNotification();
|
2019-01-28 01:54:54 +09:00
|
|
|
const getStatus = makeGetStatus();
|
2022-06-27 16:30:15 +09:00
|
|
|
const getReport = makeGetReport();
|
2016-11-21 03:39:18 +09:00
|
|
|
|
2019-01-28 01:54:54 +09:00
|
|
|
const mapStateToProps = (state, props) => {
|
|
|
|
const notification = getNotification(state, props.notification, props.accountId);
|
|
|
|
return {
|
|
|
|
notification: notification,
|
2023-01-23 21:21:50 +09:00
|
|
|
status: notification.get('status') ? getStatus(state, { id: notification.get('status'), contextType: 'notifications' }) : null,
|
2022-06-27 16:30:15 +09:00
|
|
|
report: notification.get('report') ? getReport(state, notification.get('report'), notification.getIn(['report', 'target_account', 'id'])) : null,
|
2019-01-28 01:54:54 +09:00
|
|
|
};
|
|
|
|
};
|
2016-11-21 03:39:18 +09:00
|
|
|
|
|
|
|
return mapStateToProps;
|
|
|
|
};
|
|
|
|
|
2017-10-06 08:07:59 +09:00
|
|
|
const mapDispatchToProps = dispatch => ({
|
2024-07-20 00:26:44 +09:00
|
|
|
onMention: (account) => {
|
|
|
|
dispatch(mentionCompose(account));
|
2017-10-06 08:07:59 +09:00
|
|
|
},
|
2019-01-28 01:54:54 +09:00
|
|
|
|
2021-02-11 08:53:12 +09:00
|
|
|
onModalReblog (status, privacy) {
|
2024-05-24 03:22:42 +09:00
|
|
|
dispatch(reblog({ statusId: status.get('id'), visibility: privacy }));
|
2019-01-28 01:54:54 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
onReblog (status, e) {
|
|
|
|
if (status.get('reblogged')) {
|
2024-05-24 03:22:42 +09:00
|
|
|
dispatch(unreblog({ statusId: status.get('id') }));
|
2019-01-28 01:54:54 +09:00
|
|
|
} else {
|
|
|
|
if (e.shiftKey || !boostModal) {
|
|
|
|
this.onModalReblog(status);
|
|
|
|
} else {
|
2024-03-29 00:33:15 +09:00
|
|
|
dispatch(openModal({ modalType: 'BOOST', modalProps: { status, onReblog: this.onModalReblog } }));
|
2019-01-28 01:54:54 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onFavourite (status) {
|
|
|
|
if (status.get('favourited')) {
|
|
|
|
dispatch(unfavourite(status));
|
|
|
|
} else {
|
|
|
|
dispatch(favourite(status));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onToggleHidden (status) {
|
|
|
|
if (status.get('hidden')) {
|
|
|
|
dispatch(revealStatus(status.get('id')));
|
|
|
|
} else {
|
|
|
|
dispatch(hideStatus(status.get('id')));
|
|
|
|
}
|
|
|
|
},
|
2017-10-06 08:07:59 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(makeMapStateToProps, mapDispatchToProps)(Notification);
|