From 313824b6dfcbf1ae9fe24781c6691209182940c8 Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Fri, 10 Sep 2021 13:45:24 -0400 Subject: [PATCH] [MM-38316] Remove mention and unread counts for current server from the dropdown button (#1729) --- src/renderer/components/MainPage.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/MainPage.tsx b/src/renderer/components/MainPage.tsx index 513dc840..b4fe1e01 100644 --- a/src/renderer/components/MainPage.tsx +++ b/src/renderer/components/MainPage.tsx @@ -393,8 +393,20 @@ export default class MainPage extends React.PureComponent { ); } - const totalMentionCount = Object.values(this.state.mentionCounts).reduce((sum, value) => sum + value, 0); - const totalUnreadCount = Object.values(this.state.unreadCounts).reduce((sum, value) => sum + value, 0); + const serverMatch = `${this.state.activeServerName}___TAB_[A-Z]+`; + const totalMentionCount = Object.keys(this.state.mentionCounts).reduce((sum, key) => { + // Strip out current server from unread and mention counts + if (this.state.activeServerName && key.match(serverMatch)) { + return sum; + } + return sum + this.state.mentionCounts[key]; + }, 0); + const totalUnreadCount = Object.keys(this.state.unreadCounts).reduce((sum, key) => { + if (this.state.activeServerName && key.match(serverMatch)) { + return sum; + } + return sum + this.state.unreadCounts[key]; + }, 0); const topRow = (