wrap fully qualified user IDs more intelligently

This commit is contained in:
Matthew Hodgson 2014-11-11 05:16:03 +00:00
parent 2fdf939ca9
commit 588dcf492b
4 changed files with 16 additions and 14 deletions

View file

@ -299,9 +299,10 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati
* Return the display name of an user acccording to data already downloaded
* @param {String} room_id the room id
* @param {String} user_id the id of the user
* @param {boolean} wrap whether to insert whitespace into the userid (if displayname not available) to help it wrap
* @returns {String} the user displayname or user_id if not available
*/
var getUserDisplayName = function(room_id, user_id) {
var getUserDisplayName = function(room_id, user_id, wrap) {
var displayName;
// Get the user display name from the member list of the room
@ -337,6 +338,12 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati
if (undefined === displayName) {
// By default, use the user ID
displayName = user_id;
if (wrap) {
displayName = user_id.substr(0, user_id.indexOf(':')) + " " + user_id.substr(user_id.indexOf(':'));
}
else {
displayName = user_id;
}
}
return displayName;
};
@ -589,10 +596,11 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati
* Return the display name of an user acccording to data already downloaded
* @param {String} room_id the room id
* @param {String} user_id the id of the user
* @param {boolean} wrap whether to insert whitespace into the userid (if displayname not available) to help it wrap
* @returns {String} the user displayname or user_id if not available
*/
getUserDisplayName: function(room_id, user_id) {
return getUserDisplayName(room_id, user_id);
getUserDisplayName: function(room_id, user_id, wrap) {
return getUserDisplayName(room_id, user_id, wrap);
}
};
}]);

View file

@ -114,7 +114,7 @@ function($rootScope, matrixService, eventHandlerService, modelService) {
// Return the user display name
.filter('mUserDisplayName', ['eventHandlerService', function(eventHandlerService) {
return function(user_id, room_id) {
return eventHandlerService.getUserDisplayName(room_id, user_id);
return function(user_id, room_id, wrap) {
return eventHandlerService.getUserDisplayName(room_id, user_id, wrap);
};
}]);