Merge branch 'notif-counters' into 'develop'

Chats: count only unread *chats* not total unread messages for counter

See merge request soapbox-pub/soapbox-fe!291
This commit is contained in:
Alex Gleason 2020-10-03 01:12:16 +00:00
commit dc23eff7cd
3 changed files with 6 additions and 6 deletions

View file

@ -4,10 +4,10 @@ import PropTypes from 'prop-types';
import { Helmet } from'react-helmet';
const getNotifTotals = state => {
const normNotif = state.getIn(['notifications', 'unread']);
const chatNotif = state.get('chats').reduce((acc, curr) => acc + curr.get('unread'), 0);
const notifTotals = normNotif + chatNotif;
return notifTotals;
const notifications = state.getIn(['notifications', 'unread'], 0);
const chats = state.get('chats').reduce((acc, curr) => acc + Math.min(curr.get('unread', 0), 1), 0);
const reports = state.getIn(['admin', 'open_report_count'], 0);
return notifications + chats + reports;
};
const mapStateToProps = state => ({

View file

@ -29,7 +29,7 @@ const mapStateToProps = state => {
return {
panesData: addChatsToPanes(state, panesData),
unreadCount: state.get('chats').reduce((acc, curr) => acc + curr.get('unread'), 0),
unreadCount: state.get('chats').reduce((acc, curr) => acc + Math.min(curr.get('unread', 0), 1), 0),
};
};

View file

@ -2,7 +2,7 @@ import { connect } from 'react-redux';
import IconWithBadge from 'soapbox/components/icon_with_badge';
const mapStateToProps = state => ({
count: state.get('chats').reduce((acc, curr) => acc + curr.get('unread'), 0),
count: state.get('chats').reduce((acc, curr) => acc + Math.min(curr.get('unread', 0), 1), 0),
id: 'comment',
});