diff options
author | Emmanuel ROHEE <erohee@amdocs.com> | 2014-09-15 17:31:07 +0200 |
---|---|---|
committer | Emmanuel ROHEE <erohee@amdocs.com> | 2014-09-15 17:31:07 +0200 |
commit | 8aa4b7bf7fdc31b3a146fe8fdc07922a4bfb1f78 (patch) | |
tree | 254a5f8e22853ef99294abef426a3d790df7a5de /webclient/components | |
parent | Recents uses data directly from $rootscope.events (diff) | |
download | synapse-8aa4b7bf7fdc31b3a146fe8fdc07922a4bfb1f78.tar.xz |
Recents must not show temporary fake messages
Diffstat (limited to 'webclient/components')
-rw-r--r-- | webclient/components/matrix/event-handler-service.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index a2c807b3f0..6fd77c4f29 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -353,6 +353,30 @@ angular.module('eventHandlerService', []) }, /** + * 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 room = $rootScope.events.rooms[room_id]; + if (room) { + for (var i = room.messages.length - 1; i >= 0; i--) { + var message = room.messages[i]; + + if (!filterEcho || undefined === message.echo_msg_state) { + lastMessage = message; + break; + } + } + } + + return lastMessage; + }, + + /** * Compute the room users number, ie the number of members who has joined the room. * @param {String} room_id the room id * @returns {undefined | Number} the room users number if available |