Added roomName, a directive to compute a room name based on its alias (not aliases for now) and its users displaynames or ids
This commit is contained in:
parent
99ce820cc8
commit
7d99cee3ef
|
@ -79,4 +79,43 @@ angular.module('matrixWebClient')
|
|||
return function(text) {
|
||||
return $sce.trustAsHtml(text);
|
||||
};
|
||||
}])
|
||||
|
||||
// Compute the room name according to information we have
|
||||
.filter('roomName', ['$rootScope', 'matrixService', function($rootScope, matrixService) {
|
||||
return function(room_id) {
|
||||
var roomName;
|
||||
|
||||
// If there is an alias, use it
|
||||
// TODO: only one alias is managed for now
|
||||
var alias = matrixService.getRoomIdToAliasMapping(room_id);
|
||||
if (alias) {
|
||||
roomName = alias;
|
||||
}
|
||||
|
||||
if (undefined === roomName) {
|
||||
// Else, build the name from its users
|
||||
var room = $rootScope.events.rooms[room_id];
|
||||
if (room) {
|
||||
if (room.members) {
|
||||
// Limit the room renaming to 1:1 room
|
||||
if (2 === Object.keys(room.members).length) {
|
||||
for (var i in room.members) {
|
||||
var member = room.members[i];
|
||||
if (member.user_id !== matrixService.config().user_id) {
|
||||
roomName = member.content.displayname ? member.content.displayname : member.user_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (undefined === roomName) {
|
||||
// By default, use the room ID
|
||||
roomName = room_id;
|
||||
}
|
||||
|
||||
return roomName;
|
||||
};
|
||||
}]);
|
||||
|
|
|
@ -33,8 +33,7 @@ angular.module('RecentsController', ['matrixService', 'eventHandlerService'])
|
|||
console.log("Invited to room " + event.room_id);
|
||||
// FIXME push membership to top level key to match /im/sync
|
||||
event.membership = event.content.membership;
|
||||
// FIXME bodge a nicer name than the room ID for this invite.
|
||||
event.room_display_name = event.user_id + "'s room";
|
||||
|
||||
$scope.rooms[event.room_id] = event;
|
||||
}
|
||||
});
|
||||
|
@ -88,7 +87,9 @@ angular.module('RecentsController', ['matrixService', 'eventHandlerService'])
|
|||
};
|
||||
|
||||
$scope.onInit = function() {
|
||||
refresh();
|
||||
eventHandlerService.waitForInitialSyncCompletion().then(function() {
|
||||
refresh();
|
||||
});
|
||||
};
|
||||
|
||||
}]);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
ng-class="{'recentsRoomSelected': (room.room_id === recentsSelectedRoomID)}">
|
||||
<tr>
|
||||
<td class="recentsRoomName">
|
||||
{{ room.room_display_name }}
|
||||
{{ room.room_id | roomName }}
|
||||
</td>
|
||||
<td class="recentsRoomSummaryTS">
|
||||
{{ (room.lastMsg.ts) | date:'MMM d HH:mm' }}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div id="roomHeader">
|
||||
<a href ng-click="goToPage('/')"><img src="img/logo-small.png" width="100" height="43" alt="[matrix]"/></a>
|
||||
<div id="roomName">
|
||||
{{ room_alias || room_id }}
|
||||
{{ room_id | roomName }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue