From 43cb220dcdf6b8906f1c5f9640ad7103dcf8a957 Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Fri, 13 Nov 2015 09:34:50 -0500
Subject: Made code for the member popover count a bit more robust to hopefully
 prevent issues involving old data

---
 web/react/components/popover_list_members.jsx | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

(limited to 'web/react/components/popover_list_members.jsx')

diff --git a/web/react/components/popover_list_members.jsx b/web/react/components/popover_list_members.jsx
index bd6b6d3bd..102bddcf5 100644
--- a/web/react/components/popover_list_members.jsx
+++ b/web/react/components/popover_list_members.jsx
@@ -69,7 +69,6 @@ export default class PopoverListMembers extends React.Component {
 
     render() {
         let popoverHtml = [];
-        let countText = '-';
         const members = this.props.members;
         const teamMembers = UserStore.getProfilesUsernameMap();
         const currentUserId = UserStore.getCurrentId();
@@ -148,13 +147,20 @@ export default class PopoverListMembers extends React.Component {
                     );
                 }
             });
+        }
 
-            const count = this.props.memberCount;
-            if (count > 20) {
-                countText = '20+';
-            } else if (count > 0) {
-                countText = count.toString();
-            }
+        let count = this.props.memberCount;
+        let countText = '-';
+
+        // fall back to checking the length of the member list if the count isn't set
+        if (!count && members) {
+            count = members.length;
+        }
+
+        if (count > 20) {
+            countText = '20+';
+        } else if (count > 0) {
+            countText = count.toString();
         }
 
         return (
@@ -194,6 +200,6 @@ export default class PopoverListMembers extends React.Component {
 
 PopoverListMembers.propTypes = {
     members: React.PropTypes.array.isRequired,
-    memberCount: React.PropTypes.number.isRequired,
+    memberCount: React.PropTypes.number,
     channelId: React.PropTypes.string.isRequired
 };
-- 
cgit v1.2.3-1-g7c22

