From eea64f8049d90c5dcf14a739d640f5aa6a9c7add Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Fri, 30 Jun 2017 16:06:59 +0800 Subject: [PLT-5864] Move teammate name display setting to the System Console (#6681) * move teammate name display setting to the system console * update all the likes of TeammateNameDisplay names * fix gofmt error * rebase and fix conflict --- webapp/utils/constants.jsx | 9 ++++++--- webapp/utils/utils.jsx | 20 +++++++++----------- 2 files changed, 15 insertions(+), 14 deletions(-) (limited to 'webapp/utils') diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx index b111a9900..212eedda4 100644 --- a/webapp/utils/constants.jsx +++ b/webapp/utils/constants.jsx @@ -37,8 +37,6 @@ export const Preferences = { CATEGORY_DIRECT_CHANNEL_SHOW: 'direct_channel_show', CATEGORY_GROUP_CHANNEL_SHOW: 'group_channel_show', CATEGORY_DISPLAY_SETTINGS: 'display_settings', - DISPLAY_PREFER_NICKNAME: 'nickname_full_name', - DISPLAY_PREFER_FULL_NAME: 'full_name', CATEGORY_ADVANCED_SETTINGS: 'advanced_settings', TUTORIAL_STEP: 'tutorial_step', CHANNEL_DISPLAY_MODE: 'channel_display_mode', @@ -970,7 +968,12 @@ export const Constants = { TEST_ID_COUNT: 10, CENTER: 'center', RHS: 'rhs', - RHS_ROOT: 'rhsroot' + RHS_ROOT: 'rhsroot', + TEAMMATE_NAME_DISPLAY: { + SHOW_USERNAME: 'username', + SHOW_NICKNAME_FULLNAME: 'nickname_full_name', + SHOW_FULLNAME: 'full_name' + } }; export default Constants; diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx index f35e8cd0f..16edbecdc 100644 --- a/webapp/utils/utils.jsx +++ b/webapp/utils/utils.jsx @@ -1015,21 +1015,19 @@ export function displayUsername(userId) { } export function displayUsernameForUser(user) { - const nameFormat = PreferenceStore.get(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', 'false'); - - let username = ''; if (user) { - if (nameFormat === Constants.Preferences.DISPLAY_PREFER_NICKNAME) { - username = user.nickname || getFullName(user); - } else if (nameFormat === Constants.Preferences.DISPLAY_PREFER_FULL_NAME) { - username = getFullName(user); - } - if (!username.trim().length) { - username = user.username; + const nameFormat = global.window.mm_config.TeammateNameDisplay; + let name = user.username; + if (nameFormat === Constants.TEAMMATE_NAME_DISPLAY.SHOW_NICKNAME_FULLNAME && user.nickname && user.nickname !== '') { + name = user.nickname; + } else if ((user.first_name || user.last_name) && (nameFormat === Constants.TEAMMATE_NAME_DISPLAY.SHOW_NICKNAME_FULLNAME || nameFormat === Constants.TEAMMATE_NAME_DISPLAY.SHOW_FULLNAME)) { + name = getFullName(user); } + + return name; } - return username; + return null; } // Converts a file size in bytes into a human-readable string of the form '123MB'. -- cgit v1.2.3-1-g7c22