diff options
-rw-r--r-- | syweb/webclient/components/matrix/model-service.js | 37 | ||||
-rw-r--r-- | syweb/webclient/home/home-controller.js | 13 |
2 files changed, 10 insertions, 40 deletions
diff --git a/syweb/webclient/components/matrix/model-service.js b/syweb/webclient/components/matrix/model-service.js index 578804c994..6e6f741596 100644 --- a/syweb/webclient/components/matrix/model-service.js +++ b/syweb/webclient/components/matrix/model-service.js @@ -179,43 +179,6 @@ angular.module('modelService', []) return room.current_room_state.members[user_id]; }, - /** - * Get the room_alias & room_display_name which are computed from data - * already retrieved from the server. - * @param {Room object} room one element of the array returned by the response - * of rooms() and publicRooms() - * @returns {Object} {room_alias: "...", room_display_name: "..."} - */ - getRoomAliasAndDisplayName: function(room) { - var result = { - room_alias: undefined, - room_display_name: undefined - }; - var alias = this.getRoomIdToAliasMapping(room.room_id); - if (alias) { - // use the existing alias from storage - result.room_alias = alias; - result.room_display_name = alias; - } - // XXX: this only lets us learn aliases from our local HS - we should - // make the client stop returning this if we can trust m.room.aliases state events - else if (room.aliases && room.aliases[0]) { - // save the mapping - // TODO: select the smarter alias from the array - this.createRoomIdToAliasMapping(room.room_id, room.aliases[0]); - result.room_display_name = room.aliases[0]; - result.room_alias = room.aliases[0]; - } - else if (room.membership === "invite" && "inviter" in room) { - result.room_display_name = room.inviter + "'s room"; - } - else { - // last resort use the room id - result.room_display_name = room.room_id; - } - return result; - }, - createRoomIdToAliasMapping: function(roomId, alias) { setRoomIdToAliasMapping(roomId, alias); }, diff --git a/syweb/webclient/home/home-controller.js b/syweb/webclient/home/home-controller.js index 467db09b3a..6a3c079295 100644 --- a/syweb/webclient/home/home-controller.js +++ b/syweb/webclient/home/home-controller.js @@ -54,10 +54,17 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen $scope.public_rooms = response.data.chunk; for (var i = 0; i < $scope.public_rooms.length; i++) { var room = $scope.public_rooms[i]; - - // Add room_alias & room_display_name members - angular.extend(room, modelService.getRoomAliasAndDisplayName(room)); + if (room.aliases && room.aliases.length > 0) { + room.room_display_name = room.aliases[0]; + room.room_alias = room.aliases[0]; + } + else if (room.name) { + room.room_display_name = room.name; + } + else { + room.room_display_name = room.room_id; + } } } ); |