bigbuffet-rw/app/soapbox/features/notifications/containers/notification_container.js
marcin mikołajczak af695e3812 Reducers: TypeScrpt + fixes
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-06-20 16:46:45 +02:00

74 lines
1.8 KiB
JavaScript

import { connect } from 'react-redux';
import { mentionCompose } from 'soapbox/actions/compose';
import {
reblog,
favourite,
unreblog,
unfavourite,
} from 'soapbox/actions/interactions';
import { openModal } from 'soapbox/actions/modals';
import { getSettings } from 'soapbox/actions/settings';
import {
hideStatus,
revealStatus,
} from 'soapbox/actions/statuses';
import { makeGetNotification } from 'soapbox/selectors';
import Notification from '../components/notification';
const makeMapStateToProps = () => {
const getNotification = makeGetNotification();
const mapStateToProps = (state, props) => {
return {
siteTitle: state.getIn(['instance', 'title']),
notification: getNotification(state, props.notification),
};
};
return mapStateToProps;
};
const mapDispatchToProps = dispatch => ({
onMention: (account) => {
dispatch(mentionCompose(account));
},
onModalReblog(status) {
dispatch(reblog(status));
},
onReblog(status, e) {
dispatch((_, getState) => {
const boostModal = getSettings(getState()).get('boostModal');
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')));
}
},
});
export default connect(makeMapStateToProps, mapDispatchToProps)(Notification);