summaryrefslogtreecommitdiffstats
path: root/web/react/utils/utils.jsx
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-11-02 14:10:59 -0500
committerChristopher Speller <crspeller@gmail.com>2015-11-02 14:10:59 -0500
commit17233b1dce530eef75e16944da7abdb060d2c27e (patch)
tree76aaace305ed6fac3cb22ace8064229dbfa8ea04 /web/react/utils/utils.jsx
parent16171468dd51bb60216b5b9fa26866ec0c38d81c (diff)
parentbc57489d8b9786ae15374b93e0691488972af0a6 (diff)
downloadchat-17233b1dce530eef75e16944da7abdb060d2c27e.tar.gz
chat-17233b1dce530eef75e16944da7abdb060d2c27e.tar.bz2
chat-17233b1dce530eef75e16944da7abdb060d2c27e.zip
Merge pull request #1259 from stasvovk/PLT-639
PLT-639: 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 4bd651649..296307bc6 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(user);
+ } else if (nameFormat === 'full_name') {
+ username = getFullName(user);
+ }
+ 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;