From b84af104557fa9d0a7270b62def9b7c567e23f9b Mon Sep 17 00:00:00 2001
From: Stas Vovk <stas@vovk.me>
Date: Sun, 1 Nov 2015 01:08:18 +0200
Subject: display full name, nickname or username in direct messages

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

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

diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index c7c8549b9..259fe14cd 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -884,6 +884,23 @@ export function getDisplayName(user) {
     return user.username;
 }
 
+export function displayUsername(userId) {
+    const user = UserStore.getProfile(userId);
+    const nameFormat = PreferenceStore.getPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', {value: 'false'}).value;
+
+    let username;
+    if (nameFormat === 'nickname_full_name') {
+        username = user.nickname || getFullName();
+    } else if (nameFormat === 'full_name') {
+        username = getFullName();
+    }
+    if (!username.trim().length) {
+        username = user.username;
+    }
+
+    return username;
+}
+
 //IE10 does not set window.location.origin automatically so this must be called instead when using it
 export function getWindowLocationOrigin() {
     var windowLocationOrigin = window.location.origin;
-- 
cgit v1.2.3-1-g7c22


From bc57489d8b9786ae15374b93e0691488972af0a6 Mon Sep 17 00:00:00 2001
From: Stas Vovk <stas@vovk.me>
Date: Mon, 2 Nov 2015 17:45:51 +0200
Subject: fixed errors in displayUsername

---
 web/react/utils/utils.jsx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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

diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 259fe14cd..a9dafecdc 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -888,11 +888,11 @@ export function displayUsername(userId) {
     const user = UserStore.getProfile(userId);
     const nameFormat = PreferenceStore.getPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', {value: 'false'}).value;
 
-    let username;
+    let username = '';
     if (nameFormat === 'nickname_full_name') {
-        username = user.nickname || getFullName();
+        username = user.nickname || getFullName(user);
     } else if (nameFormat === 'full_name') {
-        username = getFullName();
+        username = getFullName(user);
     }
     if (!username.trim().length) {
         username = user.username;
-- 
cgit v1.2.3-1-g7c22

