diff options
author | enahum <nahumhbl@gmail.com> | 2017-03-01 05:43:40 -0300 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2017-03-01 08:43:40 +0000 |
commit | 551adddb6717a56237b4863d08c6f3355e02b853 (patch) | |
tree | f98cd53beb385010d73905203aadb5b634bf537f | |
parent | daef8d83840460757222699c2d512c66e34432c1 (diff) | |
download | chat-551adddb6717a56237b4863d08c6f3355e02b853.tar.gz chat-551adddb6717a56237b4863d08c6f3355e02b853.tar.bz2 chat-551adddb6717a56237b4863d08c6f3355e02b853.zip |
Prevent msg count subtraction to be less than zero (#5565)
-rw-r--r-- | webapp/stores/team_store.jsx | 7 |
1 files 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; } } |