From 1dba330146a10718a2fc9eac0ae7d6e1d6bc0d79 Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Tue, 14 Jul 2015 17:07:19 -0400
Subject: Use a user's full name as their display name if a nickname hasn't
 been specified

---
 web/react/utils/utils.jsx | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

(limited to 'web/react/utils/utils.jsx')

diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 5a1a7ee73..416ea5ae4 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -825,10 +825,28 @@ module.exports.changeColor =function(col, amt) {
     return (usePound?"#":"") + String("000000" + (g | (b << 8) | (r << 16)).toString(16)).slice(-6);
 };
 
+module.exports.getFullName = function(user) {
+    if (user.first_name && user.last_name) {
+        return user.first_name + " " + user.last_name;
+    } else if (user.first_name) {
+        return user.first_name;
+    } else if (user.last_name) {
+        return user.last_name;
+    } else {
+        return "";
+    }
+};
+
 module.exports.getDisplayName = function(user) {
     if (user.nickname && user.nickname.trim().length > 0) {
         return user.nickname;
     } else {
-        return user.username;
+        var fullName = module.exports.getFullName(user);
+
+        if (fullName) {
+            return fullName;
+        } else {
+            return user.username;
+        }
     }
 };
-- 
cgit v1.2.3-1-g7c22

