Factor out room name logic: mRoomName is the canonical source.

pull/16/head
Kegan Dougal 2014-11-06 13:37:05 +00:00
parent c9c2e39531
commit 8bcd36377a
2 changed files with 6 additions and 14 deletions

View File

@ -26,8 +26,8 @@ Typically, this service will store events and broadcast them to any listeners
(e.g. controllers) via $broadcast. (e.g. controllers) via $broadcast.
*/ */
angular.module('eventHandlerService', []) angular.module('eventHandlerService', [])
.factory('eventHandlerService', ['matrixService', '$rootScope', '$q', '$timeout', 'mPresence', 'notificationService', 'modelService', .factory('eventHandlerService', ['matrixService', '$rootScope', '$q', '$timeout', '$filter', 'mPresence', 'notificationService', 'modelService',
function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService, modelService) { function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificationService, modelService) {
var ROOM_CREATE_EVENT = "ROOM_CREATE_EVENT"; var ROOM_CREATE_EVENT = "ROOM_CREATE_EVENT";
var MSG_EVENT = "MSG_EVENT"; var MSG_EVENT = "MSG_EVENT";
var MEMBER_EVENT = "MEMBER_EVENT"; var MEMBER_EVENT = "MEMBER_EVENT";
@ -135,16 +135,8 @@ function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService
else if (event.content.msgtype === "m.image") { else if (event.content.msgtype === "m.image") {
message = displayname + " sent an image."; message = displayname + " sent an image.";
} }
var roomTitle = matrixService.getRoomIdToAliasMapping(event.room_id); var roomTitle = $filter("mRoomName")(event.room_id);
var theRoom = modelService.getRoom(event.room_id);
if (!roomTitle && theRoom.current_room_state.state("m.room.name") && theRoom.current_room_state.state("m.room.name").content) {
roomTitle = theRoom.current_room_state.state("m.room.name").content.name;
}
if (!roomTitle) {
roomTitle = event.room_id;
}
notificationService.showNotification( notificationService.showNotification(
displayname + " (" + roomTitle + ")", displayname + " (" + roomTitle + ")",

View File

@ -76,8 +76,8 @@ describe("RegisterController ", function() {
scope.account.pwd1 = "password"; scope.account.pwd1 = "password";
scope.account.pwd2 = "password"; scope.account.pwd2 = "password";
scope.account.desired_user_id = "bob"; scope.account.desired_user_id = "bob";
scope.register(); scope.register(); // this depends on the result of a deferred
rootScope.$digest(); rootScope.$digest(); // which is delivered after the digest
expect(scope.feedback).not.toEqual(prevFeedback); expect(scope.feedback).not.toEqual(prevFeedback);
}); });