2016-11-21 05:39:18 +11:00
|
|
|
import { connect } from 'react-redux';
|
2019-01-28 03:54:54 +11:00
|
|
|
import { makeGetNotification, makeGetStatus } from '../../../selectors';
|
2016-11-21 05:39:18 +11:00
|
|
|
import Notification from '../components/notification';
|
2019-01-28 03:54:54 +11:00
|
|
|
import { openModal } from '../../../actions/modal';
|
2017-10-06 10:07:59 +11:00
|
|
|
import { mentionCompose } from '../../../actions/compose';
|
2019-01-28 03:54:54 +11:00
|
|
|
import {
|
|
|
|
reblog,
|
|
|
|
favourite,
|
|
|
|
unreblog,
|
|
|
|
unfavourite,
|
|
|
|
} from '../../../actions/interactions';
|
|
|
|
import {
|
|
|
|
hideStatus,
|
|
|
|
revealStatus,
|
|
|
|
} from '../../../actions/statuses';
|
|
|
|
import { boostModal } from '../../../initial_state';
|
2016-11-21 05:39:18 +11:00
|
|
|
|
|
|
|
const makeMapStateToProps = () => {
|
|
|
|
const getNotification = makeGetNotification();
|
2019-01-28 03:54:54 +11:00
|
|
|
const getStatus = makeGetStatus();
|
2016-11-21 05:39:18 +11:00
|
|
|
|
2019-01-28 03:54:54 +11:00
|
|
|
const mapStateToProps = (state, props) => {
|
|
|
|
const notification = getNotification(state, props.notification, props.accountId);
|
|
|
|
return {
|
|
|
|
notification: notification,
|
|
|
|
status: notification.get('status') ? getStatus(state, { id: notification.get('status') }) : null,
|
|
|
|
};
|
|
|
|
};
|
2016-11-21 05:39:18 +11:00
|
|
|
|
|
|
|
return mapStateToProps;
|
|
|
|
};
|
|
|
|
|
2017-10-06 10:07:59 +11:00
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
|
|
onMention: (account, router) => {
|
|
|
|
dispatch(mentionCompose(account, router));
|
|
|
|
},
|
2019-01-28 03:54:54 +11:00
|
|
|
|
|
|
|
onModalReblog (status) {
|
|
|
|
dispatch(reblog(status));
|
|
|
|
},
|
|
|
|
|
|
|
|
onReblog (status, e) {
|
|
|
|
if (status.get('reblogged')) {
|
|
|
|
dispatch(unreblog(status));
|
|
|
|
} else {
|
|
|
|
if (e.shiftKey || !boostModal) {
|
|
|
|
this.onModalReblog(status);
|
|
|
|
} else {
|
|
|
|
dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog }));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
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 10:07:59 +11:00
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(makeMapStateToProps, mapDispatchToProps)(Notification);
|