From 37f69bb4dbd877500ca210375ac2a058ed0fbe86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Thu, 5 Oct 2017 21:55:02 +0200 Subject: [PATCH] workaround for notif clearing --- .../components/notification/container.js | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/app/javascript/glitch/components/notification/container.js b/app/javascript/glitch/components/notification/container.js index e29d6ba60e..dc4c2168a9 100644 --- a/app/javascript/glitch/components/notification/container.js +++ b/app/javascript/glitch/components/notification/container.js @@ -19,38 +19,30 @@ Imports: // Package imports // import { connect } from 'react-redux'; -// Mastodon imports // -import { makeGetNotification } from '../../../mastodon/selectors'; - // Our imports // import Notification from '.'; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -/* +const mapStateToProps = (state, props) => { + // replace account id with object + let leNotif = props.notification.set('account', state.getIn(['accounts', props.notification.get('account')])); -State mapping: --------------- + // populate markedForDelete from state - is mysteriously lost somewhere + for (let n of state.getIn(['notifications', 'items'])) { + if (n.get('id') === props.notification.get('id')) { + leNotif = leNotif.set('markedForDelete', n.get('markedForDelete')); + break; + } + } -The `mapStateToProps()` function maps various state properties to the -props of our component. We wrap this in `makeMapStateToProps()` so that -we only have to call `makeGetNotification()` once instead of every -time. - -*/ - -const makeMapStateToProps = () => { - const getNotification = makeGetNotification(); - - const mapStateToProps = (state, props) => ({ - notification: getNotification(state, props.notification, props.accountId), + return ({ + notification: leNotif, settings: state.get('local_settings'), notifCleaning: state.getIn(['notifications', 'cleaningMode']), }); - - return mapStateToProps; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -export default connect(makeMapStateToProps)(Notification); +export default connect(mapStateToProps)(Notification);