summary refs log tree commit diff
path: root/webclient/components
diff options
context:
space:
mode:
authorEmmanuel ROHEE <erohee@amdocs.com>2014-09-11 09:11:24 +0200
committerEmmanuel ROHEE <erohee@amdocs.com>2014-09-11 09:11:24 +0200
commit8dcb6f24b518d668290d6a85493ff4994ddce378 (patch)
tree2b170893beed88eb4593419a5ec69fafe4c42896 /webclient/components
parentMerge remote-tracking branch 'origin/develop' into webclient_initialSync (diff)
downloadsynapse-8dcb6f24b518d668290d6a85493ff4994ddce378.tar.xz
getRoomEventIndex: improved speed for what it is used
Diffstat (limited to 'webclient/components')
-rw-r--r--webclient/components/matrix/event-handler-service.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js
index 277faa6f77..b19ec27a9d 100644
--- a/webclient/components/matrix/event-handler-service.js
+++ b/webclient/components/matrix/event-handler-service.js
@@ -205,12 +205,13 @@ angular.module('eventHandlerService', [])
      */
     var getRoomEventIndex = function(room_id, event_id) {
         var index;
-        
+
         var room = $rootScope.events.rooms[room_id];
         if (room) {
-            for (var i = 0; i < room.messages.length; i++) {
+            // Start looking from the tail since the first goal of this function 
+            // is to find a messaged among the latest ones
+            for (var i = room.messages.length - 1; i > 0; i--) {
                 var message = room.messages[i];
-                console.log(message.event_id);
                 if (event_id === message.event_id) {
                     index = i;
                     break;