From 098cbcdc21effeebe7e57fbd912a785e85cbfc5d Mon Sep 17 00:00:00 2001 From: hmhealey Date: Mon, 13 Jul 2015 17:47:57 -0400 Subject: Unify all locations where we determine a user's display named based off of their nickname/username into a helper function --- web/react/utils/utils.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'web/react/utils') diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 7186251e7..5a1a7ee73 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -796,7 +796,6 @@ module.exports.getHomeLink = function() { return window.location.protocol + "//" + parts.join("."); } - module.exports.changeColor =function(col, amt) { var usePound = false; @@ -824,5 +823,12 @@ module.exports.changeColor =function(col, amt) { else if (g < 0) g = 0; return (usePound?"#":"") + String("000000" + (g | (b << 8) | (r << 16)).toString(16)).slice(-6); +}; +module.exports.getDisplayName = function(user) { + if (user.nickname && user.nickname.trim().length > 0) { + return user.nickname; + } else { + return user.username; + } }; -- cgit v1.2.3-1-g7c22