diff options
Diffstat (limited to '')
-rw-r--r-- | syweb/webclient/components/matrix/event-handler-service.js | 23 | ||||
-rw-r--r-- | syweb/webclient/components/matrix/model-service.js | 23 | ||||
-rw-r--r-- | syweb/webclient/recents/recents-controller.js | 6 | ||||
-rw-r--r-- | syweb/webclient/recents/recents-filter.js | 8 | ||||
-rw-r--r-- | syweb/webclient/recents/recents.html | 2 |
5 files changed, 31 insertions, 31 deletions
diff --git a/syweb/webclient/components/matrix/event-handler-service.js b/syweb/webclient/components/matrix/event-handler-service.js index a41aaa5778..20ed89f161 100644 --- a/syweb/webclient/components/matrix/event-handler-service.js +++ b/syweb/webclient/components/matrix/event-handler-service.js @@ -501,30 +501,7 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati eventContainsBingWord: function(event) { return containsBingWord(event); - }, - - /** - * Return the last message event of a room - * @param {String} room_id the room id - * @param {Boolean} filterFake true to not take into account fake messages - * @returns {undefined | Event} the last message event if available - */ - getLastMessage: function(room_id, filterEcho) { - var lastMessage; - - var events = modelService.getRoom(room_id).events; - for (var i = events.length - 1; i >= 0; i--) { - var message = events[i]; - - if (!filterEcho || undefined === message.echo_msg_state) { - lastMessage = message; - break; - } - } - - return lastMessage; } - }; }]); diff --git a/syweb/webclient/components/matrix/model-service.js b/syweb/webclient/components/matrix/model-service.js index 4f5d888b05..d34981a9ff 100644 --- a/syweb/webclient/components/matrix/model-service.js +++ b/syweb/webclient/components/matrix/model-service.js @@ -307,6 +307,29 @@ angular.module('modelService', []) } return memberCount; + }, + + /** + * Return the last message event of a room + * @param {String} room_id the room id + * @param {Boolean} filterFake true to not take into account fake messages + * @returns {undefined | Event} the last message event if available + */ + getLastMessage: function(room_id, filterEcho) { + var lastMessage; + + var events = this.getRoom(room_id).events; + for (var i = events.length - 1; i >= 0; i--) { + var message = events[i]; + + // TODO: define a better marker than echo_msg_state + if (!filterEcho || undefined === message.echo_msg_state) { + lastMessage = message; + break; + } + } + + return lastMessage; } }; diff --git a/syweb/webclient/recents/recents-controller.js b/syweb/webclient/recents/recents-controller.js index 41720d4cb0..6b2915d03b 100644 --- a/syweb/webclient/recents/recents-controller.js +++ b/syweb/webclient/recents/recents-controller.js @@ -17,11 +17,11 @@ 'use strict'; angular.module('RecentsController', ['matrixService', 'matrixFilter']) -.controller('RecentsController', ['$rootScope', '$scope', 'eventHandlerService', 'modelService', 'recentsService', - function($rootScope, $scope, eventHandlerService, modelService, recentsService) { +.controller('RecentsController', ['$rootScope', '$scope', 'modelService', 'recentsService', + function($rootScope, $scope, modelService, recentsService) { // Expose the service to the view - $scope.eventHandlerService = eventHandlerService; + $scope.modelService = modelService; // retrieve all rooms and expose them $scope.rooms = modelService.getRooms(); diff --git a/syweb/webclient/recents/recents-filter.js b/syweb/webclient/recents/recents-filter.js index 00304f84dc..31859b1c7f 100644 --- a/syweb/webclient/recents/recents-filter.js +++ b/syweb/webclient/recents/recents-filter.js @@ -17,7 +17,7 @@ 'use strict'; angular.module('RecentsController') -.filter('orderRecents', ["matrixService", "eventHandlerService", "modelService", function(matrixService, eventHandlerService, modelService) { +.filter('orderRecents', ["matrixService", "modelService", function(matrixService, modelService) { return function(rooms) { var user_id = matrixService.config().user_id; @@ -39,7 +39,7 @@ angular.module('RecentsController') room.recent.inviter = member.user_id; } // Count users here - // TODO: Compute it directly in eventHandlerService + // TODO: Compute it directly in modelService room.recent.numUsersInRoom = modelService.getUserCountInRoom(room_id); filtered.push(room); @@ -54,8 +54,8 @@ angular.module('RecentsController') // The room with the latest message at first filtered.sort(function (roomA, roomB) { - var lastMsgRoomA = eventHandlerService.getLastMessage(roomA.room_id, true); - var lastMsgRoomB = eventHandlerService.getLastMessage(roomB.room_id, true); + var lastMsgRoomA = modelService.getLastMessage(roomA.room_id, true); + var lastMsgRoomB = modelService.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/syweb/webclient/recents/recents.html b/syweb/webclient/recents/recents.html index 600e1f9c1a..2596b094f7 100644 --- a/syweb/webclient/recents/recents.html +++ b/syweb/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 = eventHandlerService.getLastMessage(room.room_id, true);"" }} + {{ lastMsg = modelService.getLastMessage(room.room_id, true);"" }} {{ (lastMsg.origin_server_ts) | date:'MMM d HH:mm' }} |