From 551adddb6717a56237b4863d08c6f3355e02b853 Mon Sep 17 00:00:00 2001 From: enahum Date: Wed, 1 Mar 2017 05:43:40 -0300 Subject: Prevent msg count subtraction to be less than zero (#5565) --- webapp/stores/team_store.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webapp/stores/team_store.jsx b/webapp/stores/team_store.jsx index 1601a684a..6f81a9345 100644 --- a/webapp/stores/team_store.jsx +++ b/webapp/stores/team_store.jsx @@ -324,8 +324,11 @@ class TeamStoreClass extends EventEmitter { subtractUnread(teamId, msgs, mentions) { const member = this.my_team_members.filter((m) => m.team_id === teamId)[0]; if (member) { - member.msg_count -= msgs; - member.mention_count -= mentions; + const msgCount = member.msg_count - msgs; + const mentionCount = member.mention_count - mentions; + + member.msg_count = (msgCount > 0) ? msgCount : 0; + member.mention_count = (mentionCount > 0) ? mentionCount : 0; } } -- cgit v1.2.3-1-g7c22