From d5da6b0cef598aa4abae2ff5a2c9867d0aa64a8f Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Tue, 2 Sep 2014 13:55:14 +0200 Subject: Handle "m.room.create" in order to inform controllers about new rooms --- webclient/components/matrix/event-handler-service.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'webclient/components') 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); } }, -- cgit 1.4.1