From 17266e172ffd209c41be7a9ee319f331e725c161 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 2 Oct 2020 20:01:09 -0500 Subject: [PATCH] Chats: count only unread *chats* not total unread messages for counter --- app/soapbox/components/helmet.js | 8 ++++---- app/soapbox/features/chats/components/chat_panes.js | 2 +- app/soapbox/features/ui/components/chats_counter_icon.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/soapbox/components/helmet.js b/app/soapbox/components/helmet.js index c9c1eb5a6..0fb0e3cb5 100644 --- a/app/soapbox/components/helmet.js +++ b/app/soapbox/components/helmet.js @@ -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 => ({ diff --git a/app/soapbox/features/chats/components/chat_panes.js b/app/soapbox/features/chats/components/chat_panes.js index 876ff9666..6d5e82251 100644 --- a/app/soapbox/features/chats/components/chat_panes.js +++ b/app/soapbox/features/chats/components/chat_panes.js @@ -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), }; }; diff --git a/app/soapbox/features/ui/components/chats_counter_icon.js b/app/soapbox/features/ui/components/chats_counter_icon.js index d98cabadc..bb6d32907 100644 --- a/app/soapbox/features/ui/components/chats_counter_icon.js +++ b/app/soapbox/features/ui/components/chats_counter_icon.js @@ -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', });