summary refs log tree commit diff
path: root/webclient/components
diff options
context:
space:
mode:
authorEmmanuel ROHEE <erohee@amdocs.com>2014-09-02 13:55:14 +0200
committerEmmanuel ROHEE <erohee@amdocs.com>2014-09-02 13:55:23 +0200
commitd5da6b0cef598aa4abae2ff5a2c9867d0aa64a8f (patch)
tree34700332e7685f9edaee3da1a057d03d7f76a3d9 /webclient/components
parentOrder matters when adding REST servlets (diff)
downloadsynapse-d5da6b0cef598aa4abae2ff5a2c9867d0aa64a8f.tar.xz
Handle "m.room.create" in order to inform controllers about new rooms
Diffstat (limited to 'webclient/components')
-rw-r--r--webclient/components/matrix/event-handler-service.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js
index f248116914..d6a0600132 100644
--- a/webclient/components/matrix/event-handler-service.js
+++ b/webclient/components/matrix/event-handler-service.js
@@ -28,6 +28,7 @@ if typically all the $on method would do is update its own $scope.
 */
 angular.module('eventHandlerService', [])
 .factory('eventHandlerService', ['matrixService', '$rootScope', '$q', function(matrixService, $rootScope, $q) {
+    var ROOM_CREATE_EVENT = "ROOM_CREATE_EVENT";
     var MSG_EVENT = "MSG_EVENT";
     var MEMBER_EVENT = "MEMBER_EVENT";
     var PRESENCE_EVENT = "PRESENCE_EVENT";
@@ -48,7 +49,7 @@ angular.module('eventHandlerService', [])
             $rootScope.events.rooms[room_id].messages = [];
             $rootScope.events.rooms[room_id].members = {};
         }
-    }
+    };
 
     var resetRoomMessages = function(room_id) {
         if ($rootScope.events.rooms[room_id]) {
@@ -56,6 +57,13 @@ angular.module('eventHandlerService', [])
         }
     };
     
+    var handleRoomCreate = function(event, isLiveEvent) {
+        initRoom(event.room_id);
+
+        // For now, we do not use the event data. Simply signal it to the app controllers
+        $rootScope.$broadcast(ROOM_CREATE_EVENT, event, isLiveEvent);
+    };
+
     var handleMessage = function(event, isLiveEvent) {
         initRoom(event.room_id);
         
@@ -110,6 +118,7 @@ angular.module('eventHandlerService', [])
     };
     
     return {
+        ROOM_CREATE_EVENT: ROOM_CREATE_EVENT,
         MSG_EVENT: MSG_EVENT,
         MEMBER_EVENT: MEMBER_EVENT,
         PRESENCE_EVENT: PRESENCE_EVENT,
@@ -118,6 +127,9 @@ angular.module('eventHandlerService', [])
     
         handleEvent: function(event, isLiveEvent) {
             switch(event.type) {
+                case "m.room.create":
+                    handleRoomCreate(event, isLiveEvent);
+                    break;
                 case "m.room.message":
                     handleMessage(event, isLiveEvent);
                     break;
@@ -140,7 +152,7 @@ angular.module('eventHandlerService', [])
                     console.log(JSON.stringify(event, undefined, 4));
                     break;
             }
-            if (event.type.indexOf('m.call.') == 0) {
+            if (event.type.indexOf('m.call.') === 0) {
                 handleCallEvent(event, isLiveEvent);
             }
         },