summary refs log tree commit diff
path: root/webclient/recents
diff options
context:
space:
mode:
Diffstat (limited to 'webclient/recents')
-rw-r--r--webclient/recents/recents-controller.js7
-rw-r--r--webclient/recents/recents-filter.js9
-rw-r--r--webclient/recents/recents.html2
3 files changed, 8 insertions, 10 deletions
diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js
index 2006f13a57..ee8a41c366 100644
--- a/webclient/recents/recents-controller.js
+++ b/webclient/recents/recents-controller.js
@@ -17,8 +17,11 @@
 'use strict';
 
 angular.module('RecentsController', ['matrixService', 'matrixFilter'])
-.controller('RecentsController', ['$rootScope', 
-                               function($rootScope) {
+.controller('RecentsController', ['$rootScope', '$scope', 'eventHandlerService', 
+                               function($rootScope, $scope, eventHandlerService) {
+
+    // Expose the service to the view
+    $scope.eventHandlerService = eventHandlerService;
 
     // $rootScope of the parent where the recents component is included can override this value
     // in order to highlight a specific room in the list
diff --git a/webclient/recents/recents-filter.js b/webclient/recents/recents-filter.js
index e8a706a5d5..67fe49d4b6 100644
--- a/webclient/recents/recents-filter.js
+++ b/webclient/recents/recents-filter.js
@@ -35,14 +35,9 @@ angular.module('RecentsController')
         // And time sort them
         // The room with the lastest message at first
         filtered.sort(function (roomA, roomB) {
-            var lastMsgRoomA, lastMsgRoomB;
 
-            if (roomA.messages && 0 < roomA.messages.length) {
-                lastMsgRoomA = roomA.messages[roomA.messages.length - 1];
-            }
-            if (roomB.messages && 0 < roomB.messages.length) {
-                lastMsgRoomB = roomB.messages[roomB.messages.length - 1];
-            }
+            var lastMsgRoomA = eventHandlerService.getLastMessage(roomA.room_id, true);
+            var lastMsgRoomB = eventHandlerService.getLastMessage(roomB.room_id, true);
 
             // Invite message does not have a body message nor ts
             // Puth them at the top of the list
diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html
index eb9e269a4b..789ffc9d20 100644
--- a/webclient/recents/recents.html
+++ b/webclient/recents/recents.html
@@ -16,7 +16,7 @@
                 <td class="recentsRoomSummaryTS">
                     <!-- Use a temp var as alias to the last room message.
                          Declaring it in this way ensures the data-binding -->
-                    {{lastMsg = room.messages[room.messages.length - 1];""}}
+                    {{ lastMsg = eventHandlerService.getLastMessage(room.room_id, true);"" }}
 
                     {{ (lastMsg.ts) | date:'MMM d HH:mm' }}
                 </td>