From 81d061e74e9152c8fb4c340dd5b06329518f3299 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 11 Sep 2014 17:40:38 +0100 Subject: [PATCH] Fix bug where web client wold break trying to add the earliest token without having initialised the room if your first page of history contained only events which didn't call initRoom. Just call initRoom in handleMessages since we use it there rather than leaving it to the individual event handling methods. --- .../components/matrix/event-handler-service.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index 002a9fbd5d..0c86af1880 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -71,8 +71,6 @@ 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); }; @@ -82,8 +80,6 @@ angular.module('eventHandlerService', []) }; var handleMessage = function(event, isLiveEvent) { - initRoom(event.room_id); - if (isLiveEvent) { if (event.user_id === matrixService.config().user_id && (event.content.msgtype === "m.text" || event.content.msgtype === "m.emote") ) { @@ -114,8 +110,6 @@ angular.module('eventHandlerService', []) }; var handleRoomMember = function(event, isLiveEvent, isStateEvent) { - initRoom(event.room_id); - // if the server is stupidly re-relaying a no-op join, discard it. if (event.prev_content && event.content.membership === "join" && @@ -152,8 +146,6 @@ angular.module('eventHandlerService', []) }; var handlePowerLevels = function(event, isLiveEvent) { - initRoom(event.room_id); - // Keep the latest data. Do not care of events that come when paginating back if (!$rootScope.events.rooms[event.room_id][event.type] || isLiveEvent) { $rootScope.events.rooms[event.room_id][event.type] = event; @@ -164,8 +156,6 @@ angular.module('eventHandlerService', []) var handleRoomName = function(event, isLiveEvent) { console.log("handleRoomName " + isLiveEvent); - initRoom(event.room_id); - $rootScope.events.rooms[event.room_id][event.type] = event; $rootScope.$broadcast(NAME_EVENT, event, isLiveEvent); }; @@ -174,8 +164,6 @@ angular.module('eventHandlerService', []) var handleRoomTopic = function(event, isLiveEvent, isStateEvent) { console.log("handleRoomTopic live="+isLiveEvent); - initRoom(event.room_id); - // Add topic changes as if they were a room message if (!isStateEvent) { if (isLiveEvent) { @@ -316,6 +304,7 @@ angular.module('eventHandlerService', []) // Handle messages from /initialSync or /messages handleRoomMessages: function(room_id, messages, isLiveEvents) { + initRoom(room_id); this.handleEvents(messages.chunk, isLiveEvents); // Store how far back we've paginated