diff options
author | Kegan Dougal <kegan@matrix.org> | 2014-11-06 13:37:05 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2014-11-06 13:37:05 +0000 |
commit | 8bcd36377a04bede2e2d74dcd7f18742d0982ad5 (patch) | |
tree | 4e7ebaf21d90abcd9d6f8ee9966fa8aca760c907 /syweb/webclient | |
parent | Use .not.toEqual instead of .toNotEqual which is in a newer version of Jasmine. (diff) | |
download | synapse-8bcd36377a04bede2e2d74dcd7f18742d0982ad5.tar.xz |
Factor out room name logic: mRoomName is the canonical source.
Diffstat (limited to 'syweb/webclient')
-rw-r--r-- | syweb/webclient/components/matrix/event-handler-service.js | 16 | ||||
-rw-r--r-- | syweb/webclient/test/unit/register-controller.spec.js | 4 |
2 files changed, 6 insertions, 14 deletions
diff --git a/syweb/webclient/components/matrix/event-handler-service.js b/syweb/webclient/components/matrix/event-handler-service.js index 027c80a1b6..38a6efced7 100644 --- a/syweb/webclient/components/matrix/event-handler-service.js +++ b/syweb/webclient/components/matrix/event-handler-service.js @@ -26,8 +26,8 @@ Typically, this service will store events and broadcast them to any listeners (e.g. controllers) via $broadcast. */ angular.module('eventHandlerService', []) -.factory('eventHandlerService', ['matrixService', '$rootScope', '$q', '$timeout', 'mPresence', 'notificationService', 'modelService', -function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService, modelService) { +.factory('eventHandlerService', ['matrixService', '$rootScope', '$q', '$timeout', '$filter', 'mPresence', 'notificationService', 'modelService', +function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificationService, modelService) { var ROOM_CREATE_EVENT = "ROOM_CREATE_EVENT"; var MSG_EVENT = "MSG_EVENT"; var MEMBER_EVENT = "MEMBER_EVENT"; @@ -135,16 +135,8 @@ function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService else if (event.content.msgtype === "m.image") { message = displayname + " sent an image."; } - - var roomTitle = matrixService.getRoomIdToAliasMapping(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; - } + + var roomTitle = $filter("mRoomName")(event.room_id); notificationService.showNotification( displayname + " (" + roomTitle + ")", diff --git a/syweb/webclient/test/unit/register-controller.spec.js b/syweb/webclient/test/unit/register-controller.spec.js index ce6ef1f4e2..b5c7842358 100644 --- a/syweb/webclient/test/unit/register-controller.spec.js +++ b/syweb/webclient/test/unit/register-controller.spec.js @@ -76,8 +76,8 @@ describe("RegisterController ", function() { scope.account.pwd1 = "password"; scope.account.pwd2 = "password"; scope.account.desired_user_id = "bob"; - scope.register(); - rootScope.$digest(); + scope.register(); // this depends on the result of a deferred + rootScope.$digest(); // which is delivered after the digest expect(scope.feedback).not.toEqual(prevFeedback); }); |