Keep track of unread notifications when the notification column isn't mounted

This commit is contained in:
Thibaut Girka
2018-09-06 15:47:13 +02:00
committed by ThibG
parent 711826cb37
commit c8875b4d8a
3 changed files with 58 additions and 7 deletions

View File

@@ -8,6 +8,8 @@ import {
enterNotificationClearingMode,
expandNotifications,
scrollTopNotifications,
mountNotifications,
unmountNotifications,
} from 'flavours/glitch/actions/notifications';
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
import NotificationContainer from './containers/notification_container';
@@ -42,6 +44,12 @@ const mapDispatchToProps = dispatch => ({
onEnterCleaningMode(yes) {
dispatch(enterNotificationClearingMode(yes));
},
onMount() {
dispatch(mountNotifications());
},
onUnmount() {
dispatch(unmountNotifications());
},
dispatch,
});
@@ -62,6 +70,8 @@ export default class Notifications extends React.PureComponent {
localSettings: ImmutablePropTypes.map,
notifCleaningActive: PropTypes.bool,
onEnterCleaningMode: PropTypes.func,
onMount: PropTypes.func,
onUnmount: PropTypes.func,
};
static defaultProps = {
@@ -126,6 +136,20 @@ export default class Notifications extends React.PureComponent {
}
}
componentDidMount () {
const { onMount } = this.props;
if (onMount) {
onMount();
}
}
componentWillUnmount () {
const { onUnmount } = this.props;
if (onUnmount) {
onUnmount();
}
}
render () {
const { intl, notifications, shouldUpdateScroll, isLoading, isUnread, columnId, multiColumn, hasMore } = this.props;
const pinned = !!columnId;