summaryrefslogtreecommitdiffstats
path: root/web/react/utils/utils.jsx
diff options
context:
space:
mode:
authorStas Vovk <stas@vovk.me>2015-11-01 01:08:18 +0200
committerStas Vovk <stas@vovk.me>2015-11-01 01:08:18 +0200
commitb84af104557fa9d0a7270b62def9b7c567e23f9b (patch)
treee9cc198c7a8544fe04af9832829b41a5c2ab93d4 /web/react/utils/utils.jsx
parente646c97f5291bb23d4e1687d99ee1aab2932a7f3 (diff)
downloadchat-b84af104557fa9d0a7270b62def9b7c567e23f9b.tar.gz
chat-b84af104557fa9d0a7270b62def9b7c567e23f9b.tar.bz2
chat-b84af104557fa9d0a7270b62def9b7c567e23f9b.zip
display full name, nickname or username in direct messages
Diffstat (limited to 'web/react/utils/utils.jsx')
-rw-r--r--web/react/utils/utils.jsx17
1 files changed, 17 insertions, 0 deletions
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;